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

Function childSchema

script/ghmock/schemacmd.go:401–422  ·  view source on GitHub ↗

childSchema finds the schema for one step into a value: an array index or an object key. It looks through allOf, oneOf and anyOf.

(ref *openapi3.SchemaRef, seg string)

Source from the content-addressed store, hash-verified

399// childSchema finds the schema for one step into a value: an array index or
400// an object key. It looks through allOf, oneOf and anyOf.
401func childSchema(ref *openapi3.SchemaRef, seg string) *openapi3.SchemaRef {
402 if ref == nil || ref.Value == nil {
403 return nil
404 }
405 s := ref.Value
406 if s.Items != nil {
407 if _, err := strconv.Atoi(seg); err == nil {
408 return s.Items
409 }
410 }
411 if p := s.Properties[seg]; p != nil {
412 return p
413 }
414 for _, group := range []openapi3.SchemaRefs{s.AllOf, s.OneOf, s.AnyOf} {
415 for _, alt := range group {
416 if c := childSchema(alt, seg); c != nil {
417 return c
418 }
419 }
420 }
421 return s.AdditionalProperties.Schema
422}
423
424func missingChild(ref *openapi3.SchemaRef, walked, seg string) error {
425 place := where(walked)

Callers 1

schemaAtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected