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

Function TestGatherSchemas_ComponentSchemas

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

Source from the content-addressed store, hash-verified

9)
10
11func TestGatherSchemas_ComponentSchemas(t *testing.T) {
12 spec := &openapi3.T{
13 Components: &openapi3.Components{
14 Schemas: openapi3.Schemas{
15 "Pet": &openapi3.SchemaRef{
16 Value: &openapi3.Schema{Type: &openapi3.Types{"object"}},
17 },
18 "Owner": &openapi3.SchemaRef{
19 Value: &openapi3.Schema{Type: &openapi3.Types{"object"}},
20 },
21 },
22 },
23 }
24
25 opts := Configuration{}
26 schemas := GatherSchemas(spec, opts)
27
28 require.Len(t, schemas, 2)
29
30 // Sorted order: Owner, Pet
31 assert.Equal(t, SchemaPath{"components", "schemas", "Owner"}, schemas[0].Path)
32 assert.Equal(t, ContextComponentSchema, schemas[0].Context)
33 assert.Equal(t, "Owner", schemas[0].ComponentName)
34
35 assert.Equal(t, SchemaPath{"components", "schemas", "Pet"}, schemas[1].Path)
36 assert.Equal(t, ContextComponentSchema, schemas[1].Context)
37 assert.Equal(t, "Pet", schemas[1].ComponentName)
38}
39
40func TestGatherSchemas_ComponentParameters(t *testing.T) {
41 spec := &openapi3.T{

Callers

nothing calls this directly

Calls 2

GatherSchemasFunction · 0.85
LenMethod · 0.45

Tested by

no test coverage detected