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

Function TestGatherSchemas_AllSections

pkg/codegen/gather_test.go:277–356  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestGatherSchemas_AllSections(t *testing.T) {
278 // Spec with "Bar" in schemas, parameters, responses, requestBodies, headers
279 // This is the issue #200 scenario (cross-section collision)
280 paths := openapi3.NewPaths()
281 spec := &openapi3.T{
282 Paths: paths,
283 Components: &openapi3.Components{
284 Schemas: openapi3.Schemas{
285 "Bar": &openapi3.SchemaRef{
286 Value: &openapi3.Schema{Type: &openapi3.Types{"object"}},
287 },
288 },
289 Parameters: openapi3.ParametersMap{
290 "Bar": &openapi3.ParameterRef{
291 Value: &openapi3.Parameter{
292 Name: "Bar",
293 In: "query",
294 Schema: &openapi3.SchemaRef{
295 Value: &openapi3.Schema{Type: &openapi3.Types{"string"}},
296 },
297 },
298 },
299 },
300 Responses: openapi3.ResponseBodies{
301 "Bar": &openapi3.ResponseRef{
302 Value: &openapi3.Response{
303 Content: openapi3.Content{
304 "application/json": &openapi3.MediaType{
305 Schema: &openapi3.SchemaRef{
306 Value: &openapi3.Schema{Type: &openapi3.Types{"object"}},
307 },
308 },
309 },
310 },
311 },
312 },
313 RequestBodies: openapi3.RequestBodies{
314 "Bar": &openapi3.RequestBodyRef{
315 Value: &openapi3.RequestBody{
316 Content: openapi3.Content{
317 "application/json": &openapi3.MediaType{
318 Schema: &openapi3.SchemaRef{
319 Value: &openapi3.Schema{Type: &openapi3.Types{"object"}},
320 },
321 },
322 },
323 },
324 },
325 },
326 Headers: openapi3.Headers{
327 "Bar": &openapi3.HeaderRef{
328 Value: &openapi3.Header{
329 Parameter: openapi3.Parameter{
330 Schema: &openapi3.SchemaRef{
331 Value: &openapi3.Schema{Type: &openapi3.Types{"boolean"}},
332 },
333 },
334 },

Callers

nothing calls this directly

Calls 2

GatherSchemasFunction · 0.85
LenMethod · 0.45

Tested by

no test coverage detected