MCPcopy Create free account
hub / github.com/cli/cli / schemaTypeName

Function schemaTypeName

script/ghmock/schemacmd.go:480–505  ·  view source on GitHub ↗
(t string, ref *openapi3.SchemaRef)

Source from the content-addressed store, hash-verified

478}
479
480func schemaTypeName(t string, ref *openapi3.SchemaRef) string {
481 s := ref.Value
482 switch t {
483 case "array":
484 if s.Items == nil {
485 return "list"
486 }
487 item := describeSchemaType(s.Items)
488 if strings.Contains(item, " or ") || strings.Contains(item, ", one of ") {
489 item = "(" + item + ")"
490 }
491 return "list of " + item
492 case "object":
493 if name := refName(ref); name != "" {
494 return "object (" + name + ")"
495 }
496 return "object"
497 case "string":
498 if s.Format != "" {
499 return "string (" + s.Format + ")"
500 }
501 return "string"
502 default:
503 return t
504 }
505}
506
507// refName is the last part of a schema's $ref, such as simple-user.
508func refName(ref *openapi3.SchemaRef) string {

Callers 1

describeSchemaTypeFunction · 0.85

Calls 3

describeSchemaTypeFunction · 0.85
refNameFunction · 0.85
ContainsMethod · 0.80

Tested by

no test coverage detected