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

Function propertyNames

script/ghmock/schemacmd.go:575–600  ·  view source on GitHub ↗

propertyNames lists every key a schema allows, including in oneOf and anyOf alternatives.

(s *openapi3.Schema)

Source from the content-addressed store, hash-verified

573// propertyNames lists every key a schema allows, including in oneOf and anyOf
574// alternatives.
575func propertyNames(s *openapi3.Schema) []string {
576 if s == nil {
577 return nil
578 }
579 seen := map[string]bool{}
580 var names []string
581 var add func(*openapi3.Schema)
582 add = func(s *openapi3.Schema) {
583 if s == nil {
584 return
585 }
586 for name := range s.Properties {
587 if !seen[name] {
588 seen[name] = true
589 names = append(names, name)
590 }
591 }
592 for _, group := range []openapi3.SchemaRefs{s.AllOf, s.OneOf, s.AnyOf} {
593 for _, alt := range group {
594 add(alt.Value)
595 }
596 }
597 }
598 add(s)
599 return names
600}
601
602func writeDescription(w io.Writer, text string) {
603 if text = strings.TrimSpace(text); text != "" {

Callers 1

missingChildFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected