buildAttributeSchema initializes the given JSON schema that corresponds to the given attribute.
(api *expr.APIExpr, s *Schema, at *expr.AttributeExpr)
| 499 | // buildAttributeSchema initializes the given JSON schema that corresponds to |
| 500 | // the given attribute. |
| 501 | func buildAttributeSchema(api *expr.APIExpr, s *Schema, at *expr.AttributeExpr) *Schema { |
| 502 | s.Merge(TypeSchema(api, at.Type)) |
| 503 | if s.Ref != "" { |
| 504 | // Ref is exclusive with other fields |
| 505 | return s |
| 506 | } |
| 507 | s.DefaultValue = ToStringMap(at.DefaultValue) |
| 508 | s.Description = at.Description |
| 509 | s.Example = at.Example(api.ExampleGenerator) |
| 510 | s.Extensions = ExtensionsFromExpr(at.Meta) |
| 511 | if ap := AdditionalPropertiesFromExpr(at.Meta); ap != nil { |
| 512 | s.AdditionalProperties = ap |
| 513 | } |
| 514 | initAttributeValidation(s, at) |
| 515 | |
| 516 | return s |
| 517 | } |
| 518 | |
| 519 | // initAttributeValidation initializes validation rules for an attribute. |
| 520 | func initAttributeValidation(s *Schema, at *expr.AttributeExpr) { |
no test coverage detected