MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / isExtensionOnlySchema

Function isExtensionOnlySchema

pkg/codegen/merge_schemas.go:127–150  ·  view source on GitHub ↗

isExtensionOnlySchema reports whether a schema carries only extensions, with no structural or constraint-bearing content. Used to detect the "$ref + sibling extension" idiom: allOf wrappers whose purpose is attaching extensions to a $ref (since OpenAPI 3.0 disallows sibling keys next to $ref). Impl

(s *openapi3.Schema)

Source from the content-addressed store, hash-verified

125// behavior if kin-openapi gains new structural fields: they'd be non-zero
126// by default and correctly disqualify.
127func isExtensionOnlySchema(s *openapi3.Schema) bool {
128 if s == nil || len(s.Extensions) == 0 {
129 return false
130 }
131 tmp := *s
132 tmp.Extensions = nil
133 // Source-tracking metadata from kin-openapi; always non-nil for
134 // schemas parsed from a file.
135 tmp.Origin = nil
136 // Purely documentary / metadata fields. These don't affect the
137 // generated Go type, so a schema carrying only these plus extensions
138 // still behaves as a decorator.
139 tmp.Title = ""
140 tmp.Description = ""
141 tmp.Default = nil
142 tmp.Example = nil
143 tmp.ExternalDocs = nil
144 tmp.Deprecated = false
145 tmp.ReadOnly = false
146 tmp.WriteOnly = false
147 tmp.AllowEmptyValue = false
148 tmp.XML = nil
149 return reflect.DeepEqual(tmp, openapi3.Schema{})
150}
151
152// valueWithPropagatedRef returns a copy of ref's schema with its Properties
153// refs rewritten when ref itself is external, and with extensions placed

Callers 1

mergeSchemasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…