MCPcopy Create free account
hub / github.com/goadesign/goa / buildAttributeSchema

Function buildAttributeSchema

http/codegen/openapi/json_schema.go:501–517  ·  view source on GitHub ↗

buildAttributeSchema initializes the given JSON schema that corresponds to the given attribute.

(api *expr.APIExpr, s *Schema, at *expr.AttributeExpr)

Source from the content-addressed store, hash-verified

499// buildAttributeSchema initializes the given JSON schema that corresponds to
500// the given attribute.
501func 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.
520func initAttributeValidation(s *Schema, at *expr.AttributeExpr) {

Callers 3

TypeSchemaWithPrefixFunction · 0.85
buildResultTypeSchemaFunction · 0.85

Calls 7

TypeSchemaFunction · 0.85
ToStringMapFunction · 0.85
ExtensionsFromExprFunction · 0.85
initAttributeValidationFunction · 0.85
ExampleMethod · 0.65
MergeMethod · 0.45

Tested by

no test coverage detected