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

Function GatherSchemas

pkg/codegen/gather.go:110–131  ·  view source on GitHub ↗

GatherSchemas walks the entire OpenAPI spec and collects all schemas that will need Go type names. This is the first pass of the multi-pass resolution.

(spec *openapi3.T, opts Configuration)

Source from the content-addressed store, hash-verified

108// GatherSchemas walks the entire OpenAPI spec and collects all schemas that
109// will need Go type names. This is the first pass of the multi-pass resolution.
110func GatherSchemas(spec *openapi3.T, opts Configuration) []*GatheredSchema {
111 var schemas []*GatheredSchema
112
113 if spec.Components != nil {
114 schemas = slices.Concat(
115 gatherComponentSchemas(spec.Components),
116 gatherComponentParameters(spec.Components),
117 gatherComponentResponses(spec.Components),
118 gatherComponentRequestBodies(spec.Components),
119 gatherComponentHeaders(spec.Components),
120 )
121 }
122
123 // Gather client response wrapper types for operations that will generate
124 // client code. These synthetic entries exist so wrapper types like
125 // `CreateChatCompletionResponse` participate in collision detection.
126 if opts.Generate.Client {
127 schemas = append(schemas, gatherClientResponseWrappers(spec)...)
128 }
129
130 return schemas
131}
132
133func gatherComponentSchemas(components *openapi3.Components) []*GatheredSchema {
134 var result []*GatheredSchema

Calls 6

gatherComponentSchemasFunction · 0.85
gatherComponentResponsesFunction · 0.85
gatherComponentHeadersFunction · 0.85