(att *expr.AttributeExpr, h hash.Hash64, seen map[string]*uint64)
| 404 | } |
| 405 | |
| 406 | func hashAttribute(att *expr.AttributeExpr, h hash.Hash64, seen map[string]*uint64) *uint64 { |
| 407 | t := att.Type |
| 408 | if h, ok := seen[t.Hash()]; ok { |
| 409 | return h |
| 410 | } |
| 411 | var res *uint64 |
| 412 | { |
| 413 | var tmp uint64 |
| 414 | res = &tmp |
| 415 | } |
| 416 | seen[t.Hash()] = res |
| 417 | |
| 418 | hv := hashValidation(att.Validation, h) |
| 419 | switch t.Kind() { |
| 420 | case expr.ObjectKind: |
| 421 | o := expr.AsObject(t) |
| 422 | for _, m := range *o { |
| 423 | if !openapi.MustGenerate(m.Attribute.Meta) { |
| 424 | continue |
| 425 | } |
| 426 | kh := hashString(m.Name, h) |
| 427 | vh := hashAttribute(m.Attribute, h, seen) |
| 428 | *res ^= orderedHash(kh, *vh, h) |
| 429 | } |
| 430 | if hv != 0 { |
| 431 | *res = orderedHash(*res, hv, h) |
| 432 | } |
| 433 | |
| 434 | case expr.ArrayKind: |
| 435 | kh := hashString("[]", h) |
| 436 | vh := hashAttribute(expr.AsArray(t).ElemType, h, seen) |
| 437 | *res = orderedHash(kh, *vh, h) |
| 438 | if hv != 0 { |
| 439 | *res = orderedHash(*res, hv, h) |
| 440 | } |
| 441 | |
| 442 | case expr.MapKind: |
| 443 | m := expr.AsMap(t) |
| 444 | kh := hashAttribute(m.KeyType, h, seen) |
| 445 | vh := hashAttribute(m.ElemType, h, seen) |
| 446 | *res = orderedHash(*kh, *vh, h) |
| 447 | if hv != 0 { |
| 448 | *res = orderedHash(*res, hv, h) |
| 449 | } |
| 450 | |
| 451 | case expr.UserTypeKind: |
| 452 | *res = *hashAttribute(t.(expr.UserType).Attribute(), h, seen) |
| 453 | |
| 454 | case expr.ResultTypeKind: |
| 455 | // The identifier specified in the design for result types should drive |
| 456 | // the computation of the hash. |
| 457 | rt := t.(*expr.ResultTypeExpr) |
| 458 | *res = hashString(rt.Identifier, h) |
| 459 | if view, ok := rt.Meta.Last(expr.ViewMetaKey); ok { |
| 460 | *res = orderedHash(*res, hashString(view, h), h) |
| 461 | } |
| 462 | |
| 463 | default: // Primitives or Any |
no test coverage detected