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

Function gatherComponentRequestBodies

pkg/codegen/gather.go:215–246  ·  view source on GitHub ↗
(components *openapi3.Components)

Source from the content-addressed store, hash-verified

213}
214
215func gatherComponentRequestBodies(components *openapi3.Components) []*GatheredSchema {
216 var result []*GatheredSchema
217 for _, name := range SortedMapKeys(components.RequestBodies) {
218 bodyRef := components.RequestBodies[name]
219 if bodyRef == nil || bodyRef.Value == nil {
220 continue
221 }
222 body := bodyRef.Value
223 var goNameOverride string
224 if bodyRef.Ref == "" {
225 goNameOverride = extractGoNameOverride(body.Extensions)
226 }
227 for _, mediaType := range SortedMapKeys(body.Content) {
228 if !util.IsMediaTypeJson(mediaType) {
229 continue
230 }
231 mt := body.Content[mediaType]
232 if mt.Schema != nil && mt.Schema.Value != nil {
233 result = append(result, &GatheredSchema{
234 Path: SchemaPath{"components", "requestBodies", name, "content", mediaType},
235 Context: ContextComponentRequestBody,
236 Ref: bodyRef.Ref,
237 Schema: mt.Schema.Value,
238 ContentType: mediaType,
239 ComponentName: name,
240 GoNameOverride: goNameOverride,
241 })
242 }
243 }
244 }
245 return result
246}
247
248func gatherComponentHeaders(components *openapi3.Components) []*GatheredSchema {
249 var result []*GatheredSchema

Callers 1

GatherSchemasFunction · 0.85

Calls 3

IsMediaTypeJsonFunction · 0.92
SortedMapKeysFunction · 0.85
extractGoNameOverrideFunction · 0.85

Tested by

no test coverage detected