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

Function TypeRefWithPrefix

http/codegen/openapi/json_schema.go:263–275  ·  view source on GitHub ↗

TypeRefWithPrefix produces the JSON reference to the type definition and adds the provided prefix to the type name

(api *expr.APIExpr, ut *expr.UserTypeExpr, prefix string)

Source from the content-addressed store, hash-verified

261// TypeRefWithPrefix produces the JSON reference to the type definition and adds the provided prefix
262// to the type name
263func TypeRefWithPrefix(api *expr.APIExpr, ut *expr.UserTypeExpr, prefix string) string {
264 typeName := ut.TypeName
265 if prefix != "" {
266 typeName = codegen.Goify(prefix, true) + codegen.Goify(ut.TypeName, true)
267 }
268 if n, ok := ut.Meta["openapi:typename"]; ok {
269 typeName = codegen.Goify(n[0], true)
270 }
271 if _, ok := Definitions[typeName]; !ok {
272 GenerateTypeDefinitionWithName(api, ut, typeName)
273 }
274 return fmt.Sprintf("#/$defs/%s", typeName)
275}
276
277// GenerateResultTypeDefinition produces the JSON schema corresponding to the
278// given media type and given view.

Callers 2

TypeRefFunction · 0.85
TypeSchemaWithPrefixFunction · 0.85

Calls 2

GoifyFunction · 0.92

Tested by

no test coverage detected