diff --git a/openapi3/_testdata/openapi.json b/openapi3/_testdata/openapi.json index 21a959b..79ac852 100644 --- a/openapi3/_testdata/openapi.json +++ b/openapi3/_testdata/openapi.json @@ -60,7 +60,7 @@ {"name":"in_path","in":"path","required":true,"schema":{"type":"integer"}}, {"name":"in_cookie","in":"cookie","deprecated":true,"schema":{"type":"string","deprecated":true}}, {"name":"in_header","in":"header","schema":{"type":"number"}}, - {"name":"uuid","in":"header","schema":{"$ref":"#/components/schemas/HeaderOpenapi3TestUUID"}} + {"name":"uuid","in":"header","schema":{"$ref":"#/components/schemas/Openapi3TestUUID"}} ], "requestBody":{ "content":{ @@ -102,7 +102,6 @@ "upload2":{"$ref":"#/components/schemas/FormDataMultipartFileHeader"} } }, - "HeaderOpenapi3TestUUID":{"type":"array","items":{"minimum":0,"type":"integer"},"nullable":true}, "Openapi3TestReq":{"type":"object","properties":{"in_body1":{"type":"integer"},"in_body2":{"type":"string"}}}, "Openapi3TestResp":{ "title":"Sample Response","type":"object", diff --git a/openapi3/_testdata/openapi_req2.json b/openapi3/_testdata/openapi_req2.json index 395f49e..f7658ea 100644 --- a/openapi3/_testdata/openapi_req2.json +++ b/openapi3/_testdata/openapi_req2.json @@ -20,4 +20,4 @@ } } } -} \ No newline at end of file +} diff --git a/openapi3/example_test.go b/openapi3/example_test.go index 40ebd9c..eac3617 100644 --- a/openapi3/example_test.go +++ b/openapi3/example_test.go @@ -555,14 +555,14 @@ func ExampleReflector_AddOperation_queryObject() { // - content: // application/json: // schema: - // $ref: '#/components/schemas/QueryOpenapi3TestJsonFilter' + // $ref: '#/components/schemas/Openapi3TestJsonFilter' // in: query // name: json_filter // - explode: true // in: query // name: deep_object_filter // schema: - // $ref: '#/components/schemas/QueryOpenapi3TestDeepObjectFilter' + // $ref: '#/components/schemas/Openapi3TestDeepObjectFilter' // style: deepObject // - in: path // name: id @@ -575,7 +575,7 @@ func ExampleReflector_AddOperation_queryObject() { // description: No Content // components: // schemas: - // QueryOpenapi3TestDeepObjectFilter: + // Openapi3TestDeepObjectFilter: // properties: // baz: // type: boolean @@ -587,7 +587,7 @@ func ExampleReflector_AddOperation_queryObject() { // quux: // type: number // type: object - // QueryOpenapi3TestJsonFilter: + // Openapi3TestJsonFilter: // properties: // bar: // type: integer diff --git a/openapi3/reflect.go b/openapi3/reflect.go index 70820c6..b5759eb 100644 --- a/openapi3/reflect.go +++ b/openapi3/reflect.go @@ -456,13 +456,12 @@ func (r *Reflector) parseParametersIn( return nil } - defNamePrefix := strings.Title(string(in)) - definitionsPrefix := componentsSchemas + defNamePrefix + definitionsPrefix := componentsSchemas s, err := r.Reflect(input, openapi.WithOperationCtx(oc, false, in), jsonschema.DefinitionsPrefix(definitionsPrefix), - jsonschema.CollectDefinitions(r.collectDefinition(defNamePrefix)), + jsonschema.CollectDefinitions(r.collectDefinition()), jsonschema.PropertyNameMapping(propertyMapping), jsonschema.PropertyNameTag(string(in), additionalTags...), func(rc *jsonschema.ReflectContext) { @@ -513,7 +512,7 @@ func (r *Reflector) parseParametersIn( propertySchema, err := r.Reflect(property, openapi.WithOperationCtx(oc, false, in), jsonschema.DefinitionsPrefix(definitionsPrefix), - jsonschema.CollectDefinitions(r.collectDefinition(defNamePrefix)), + jsonschema.CollectDefinitions(r.collectDefinition()), jsonschema.RootRef, sanitizeDefName, ) @@ -588,10 +587,8 @@ func sanitizeDefName(rc *jsonschema.ReflectContext) { })(rc) } -func (r *Reflector) collectDefinition(namePrefix string) func(name string, schema jsonschema.Schema) { +func (r *Reflector) collectDefinition() func(name string, schema jsonschema.Schema) { return func(name string, schema jsonschema.Schema) { - name = namePrefix + name - if _, exists := r.SpecEns().ComponentsEns().SchemasEns().MapOfSchemaOrRefValues[name]; exists { return } @@ -784,7 +781,7 @@ func (r *Reflector) parseJSONResponse(resp *Response, oc openapi.OperationContex openapi.WithOperationCtx(oc, true, openapi.InBody), jsonschema.RootRef, jsonschema.DefinitionsPrefix(componentsSchemas), - jsonschema.CollectDefinitions(r.collectDefinition("")), + jsonschema.CollectDefinitions(r.collectDefinition()), sanitizeDefName, ) if err != nil { diff --git a/openapi3/reflect_deprecated_test.go b/openapi3/reflect_deprecated_test.go index 81046a4..82218c7 100644 --- a/openapi3/reflect_deprecated_test.go +++ b/openapi3/reflect_deprecated_test.go @@ -397,7 +397,7 @@ func TestReflector_SetupRequest_queryNamedObject(t *testing.T) { "parameters":[ { "name":"in_query","in":"query","style":"deepObject","explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestLabels"} + "schema":{"$ref":"#/components/schemas/Openapi3TestLabels"} } ], "responses":{"204":{"description":"No Content"}} @@ -406,12 +406,12 @@ func TestReflector_SetupRequest_queryNamedObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestLabels":{"type":"object","additionalProperties":{"type":"number"}} + "Openapi3TestLabels":{"type":"object","additionalProperties":{"type":"number"}} } } }`, s) - js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/QueryOpenapi3TestLabels") + js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/Openapi3TestLabels") assert.True(t, found) assertjson.EqMarshal(t, `{"type":"object","additionalProperties":{"type":"number"}}`, js) } @@ -446,17 +446,13 @@ func TestReflector_SetupRequest_jsonQuery(t *testing.T) { { "name":"one","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi3TestFilter"}} } }, { "name":"two","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi3TestFilter"}} } }, { @@ -470,7 +466,7 @@ func TestReflector_SetupRequest_jsonQuery(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestFilter":{ + "Openapi3TestFilter":{ "type":"object", "properties":{ "labels":{"type":"array","items":{"type":"string"}}, @@ -823,14 +819,14 @@ func TestReflector_SetRequest_queryObject(t *testing.T) { "name":"json_filter","in":"query", "content":{ "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestJsonFilter"} + "schema":{"$ref":"#/components/schemas/Openapi3TestJsonFilter"} } } }, { "name":"deep_object_filter","in":"query","style":"deepObject", "explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestDeepObjectFilter"} + "schema":{"$ref":"#/components/schemas/Openapi3TestDeepObjectFilter"} }, { "name":"id","in":"path","required":true, @@ -843,7 +839,7 @@ func TestReflector_SetRequest_queryObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestDeepObjectFilter":{ + "Openapi3TestDeepObjectFilter":{ "type":"object", "properties":{ "baz":{"type":"boolean"}, @@ -851,7 +847,7 @@ func TestReflector_SetRequest_queryObject(t *testing.T) { "quux":{"type":"number"} } }, - "QueryOpenapi3TestJsonFilter":{ + "Openapi3TestJsonFilter":{ "type":"object", "properties":{ "bar":{"type":"integer"}, diff --git a/openapi3/reflect_test.go b/openapi3/reflect_test.go index 3e62f79..24eba68 100644 --- a/openapi3/reflect_test.go +++ b/openapi3/reflect_test.go @@ -517,7 +517,7 @@ func TestReflector_AddOperation_request_queryNamedObject(t *testing.T) { "parameters":[ { "name":"in_query","in":"query","style":"deepObject","explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestLabels"} + "schema":{"$ref":"#/components/schemas/Openapi3TestLabels"} } ], "responses":{"204":{"description":"No Content"}} @@ -526,12 +526,12 @@ func TestReflector_AddOperation_request_queryNamedObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestLabels":{"type":"object","additionalProperties":{"type":"number"}} + "Openapi3TestLabels":{"type":"object","additionalProperties":{"type":"number"}} } } }`, s) - js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/QueryOpenapi3TestLabels") + js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/Openapi3TestLabels") assert.True(t, found) assertjson.EqMarshal(t, `{"type":"object","additionalProperties":{"type":"number"}}`, js) } @@ -565,17 +565,13 @@ func TestReflector_AddOperation_request_jsonQuery(t *testing.T) { { "name":"one","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi3TestFilter"}} } }, { "name":"two","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi3TestFilter"}} } }, { @@ -589,7 +585,7 @@ func TestReflector_AddOperation_request_jsonQuery(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestFilter":{ + "Openapi3TestFilter":{ "type":"object", "properties":{ "labels":{"type":"array","items":{"type":"string"}}, @@ -949,14 +945,14 @@ func TestReflector_AddOperation_request_queryObject_deepObject(t *testing.T) { "name":"json_filter","in":"query", "content":{ "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestJsonFilter"} + "schema":{"$ref":"#/components/schemas/Openapi3TestJsonFilter"} } } }, { "name":"deep_object_filter","in":"query","style":"deepObject", "explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi3TestDeepObjectFilter"} + "schema":{"$ref":"#/components/schemas/Openapi3TestDeepObjectFilter"} }, { "name":"id","in":"path","required":true, @@ -969,7 +965,7 @@ func TestReflector_AddOperation_request_queryObject_deepObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi3TestDeepObjectFilter":{ + "Openapi3TestDeepObjectFilter":{ "type":"object", "properties":{ "baz":{"type":"boolean"}, @@ -977,7 +973,7 @@ func TestReflector_AddOperation_request_queryObject_deepObject(t *testing.T) { "quux":{"type":"number"} } }, - "QueryOpenapi3TestJsonFilter":{ + "Openapi3TestJsonFilter":{ "type":"object", "properties":{ "bar":{"type":"integer"}, diff --git a/openapi31/_testdata/openapi.json b/openapi31/_testdata/openapi.json index b6837cb..34c2276 100644 --- a/openapi31/_testdata/openapi.json +++ b/openapi31/_testdata/openapi.json @@ -6,23 +6,15 @@ "get":{ "parameters":[ { - "name":"in_query1","in":"query","description":"Query parameter.", - "required":true, + "name":"in_query1","in":"query","description":"Query parameter.","required":true, "schema":{"description":"Query parameter.","type":"integer"} }, { - "name":"in_query3","in":"query","description":"Query parameter.", - "required":true, + "name":"in_query3","in":"query","description":"Query parameter.","required":true, "schema":{"description":"Query parameter.","type":"integer"} }, - { - "name":"in_path","in":"path","required":true, - "schema":{"type":"integer"} - }, - { - "name":"in_cookie","in":"cookie","deprecated":true, - "schema":{"deprecated":true,"type":"string"} - }, + {"name":"in_path","in":"path","required":true,"schema":{"type":"integer"}}, + {"name":"in_cookie","in":"cookie","deprecated":true,"schema":{"deprecated":true,"type":"string"}}, {"name":"in_header","in":"header","schema":{"type":"number"}} ], "responses":{ @@ -34,69 +26,46 @@ "schema":{"description":"Sample header response.","type":"string"} } }, - "content":{ - "application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestResp"}} - } + "content":{"application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestResp"}}} } } }, "post":{ "parameters":[ { - "name":"in_query1","in":"query","description":"Query parameter.", - "required":true, + "name":"in_query1","in":"query","description":"Query parameter.","required":true, "schema":{"description":"Query parameter.","type":"integer"} }, { - "name":"in_query2","in":"query","description":"Query parameter.", - "required":true, + "name":"in_query2","in":"query","description":"Query parameter.","required":true, "schema":{"description":"Query parameter.","type":"integer"} }, { - "name":"in_query3","in":"query","description":"Query parameter.", - "required":true, + "name":"in_query3","in":"query","description":"Query parameter.","required":true, "schema":{"description":"Query parameter.","type":"integer"} }, + {"name":"array_csv","in":"query","schema":{"items":{"type":"string"},"type":["array","null"]},"explode":false}, { - "name":"array_csv","in":"query", - "schema":{"items":{"type":"string"},"type":["array","null"]}, + "name":"array_swg2_csv","in":"query","schema":{"items":{"type":"string"},"type":["array","null"]},"style":"form", "explode":false }, { - "name":"array_swg2_csv","in":"query", - "schema":{"items":{"type":"string"},"type":["array","null"]}, - "style":"form","explode":false - }, - { - "name":"array_swg2_ssv","in":"query", - "schema":{"items":{"type":"string"},"type":["array","null"]}, + "name":"array_swg2_ssv","in":"query","schema":{"items":{"type":"string"},"type":["array","null"]}, "style":"spaceDelimited","explode":false }, { - "name":"array_swg2_pipes","in":"query", - "schema":{"items":{"type":"string"},"type":["array","null"]}, + "name":"array_swg2_pipes","in":"query","schema":{"items":{"type":"string"},"type":["array","null"]}, "style":"pipeDelimited","explode":false }, - { - "name":"in_path","in":"path","required":true, - "schema":{"type":"integer"} - }, - { - "name":"in_cookie","in":"cookie","deprecated":true, - "schema":{"deprecated":true,"type":"string"} - }, + {"name":"in_path","in":"path","required":true,"schema":{"type":"integer"}}, + {"name":"in_cookie","in":"cookie","deprecated":true,"schema":{"deprecated":true,"type":"string"}}, {"name":"in_header","in":"header","schema":{"type":"number"}}, - { - "name":"uuid","in":"header", - "schema":{"$ref":"#/components/schemas/HeaderOpenapi31TestUUID"} - } + {"name":"uuid","in":"header","schema":{"$ref":"#/components/schemas/Openapi31TestUUID"}} ], "requestBody":{ "content":{ "application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestReq"}}, - "multipart/form-data":{ - "schema":{"$ref":"#/components/schemas/FormDataOpenapi31TestReq"} - } + "multipart/form-data":{"schema":{"$ref":"#/components/schemas/FormDataOpenapi31TestReq"}} } }, "responses":{ @@ -108,19 +77,12 @@ "schema":{"description":"Sample header response.","type":"string"} } }, - "content":{ - "application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestResp"}} - } + "content":{"application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestResp"}}} }, "409":{ "description":"Conflict", "content":{ - "application/json":{ - "schema":{ - "items":{"$ref":"#/components/schemas/Openapi31TestResp"}, - "type":["null","array"] - } - }, + "application/json":{"schema":{"items":{"$ref":"#/components/schemas/Openapi31TestResp"},"type":["null","array"]}}, "text/html":{"schema":{"type":"string"}} } } @@ -140,37 +102,21 @@ }, "type":"object" }, - "HeaderOpenapi31TestUUID":{"items":{"minimum":0,"type":"integer"},"type":["array","null"]}, - "Openapi31TestReq":{ - "properties":{"in_body1":{"type":"integer"},"in_body2":{"type":"string"}}, - "type":"object" - }, + "Openapi31TestReq":{"properties":{"in_body1":{"type":"integer"},"in_body2":{"type":"string"}},"type":"object"}, "Openapi31TestResp":{ "description":"This is a sample response.", "properties":{ - "arrayOfAnything":{"items":{},"type":"array"}, - "field1":{"type":"integer"},"field2":{"type":"string"}, + "arrayOfAnything":{"items":{},"type":"array"},"field1":{"type":"integer"},"field2":{"type":"string"}, "info":{ - "properties":{ - "bar":{"description":"This is Bar.","type":"number"}, - "foo":{"default":"baz","pattern":"\\d+","type":"string"} - }, + "properties":{"bar":{"description":"This is Bar.","type":"number"},"foo":{"default":"baz","pattern":"\\d+","type":"string"}}, "required":["foo"],"type":"object" }, "map":{"additionalProperties":{"type":"integer"},"type":"object"}, - "mapOfAnything":{"additionalProperties":{},"type":"object"}, - "nullableWhatever":{}, + "mapOfAnything":{"additionalProperties":{},"type":"object"},"nullableWhatever":{}, "parent":{"$ref":"#/components/schemas/Openapi31TestResp"}, - "recursiveArray":{ - "items":{"$ref":"#/components/schemas/Openapi31TestResp"}, - "type":"array" - }, - "recursiveStructArray":{ - "items":{"$ref":"#/components/schemas/Openapi31TestResp"}, - "type":"array" - }, - "uuid":{"$ref":"#/components/schemas/Openapi31TestUUID"}, - "whatever":{} + "recursiveArray":{"items":{"$ref":"#/components/schemas/Openapi31TestResp"},"type":"array"}, + "recursiveStructArray":{"items":{"$ref":"#/components/schemas/Openapi31TestResp"},"type":"array"}, + "uuid":{"$ref":"#/components/schemas/Openapi31TestUUID"},"whatever":{} }, "title":"Sample Response","type":"object","x-foo":"bar" }, diff --git a/openapi31/example_test.go b/openapi31/example_test.go index 347f858..b21dae0 100644 --- a/openapi31/example_test.go +++ b/openapi31/example_test.go @@ -235,14 +235,14 @@ func ExampleReflector_AddOperation_queryObject() { // - content: // application/json: // schema: - // $ref: '#/components/schemas/QueryOpenapi31TestJsonFilter' + // $ref: '#/components/schemas/Openapi31TestJsonFilter' // in: query // name: json_filter // - explode: true // in: query // name: deep_object_filter // schema: - // $ref: '#/components/schemas/QueryOpenapi31TestDeepObjectFilter' + // $ref: '#/components/schemas/Openapi31TestDeepObjectFilter' // style: deepObject // - in: path // name: id @@ -256,7 +256,7 @@ func ExampleReflector_AddOperation_queryObject() { // description: No Content // components: // schemas: - // QueryOpenapi31TestDeepObjectFilter: + // Openapi31TestDeepObjectFilter: // properties: // baz: // type: boolean @@ -268,7 +268,7 @@ func ExampleReflector_AddOperation_queryObject() { // quux: // type: number // type: object - // QueryOpenapi31TestJsonFilter: + // Openapi31TestJsonFilter: // properties: // bar: // type: integer diff --git a/openapi31/reflect.go b/openapi31/reflect.go index c0016c0..e1b15ba 100644 --- a/openapi31/reflect.go +++ b/openapi31/reflect.go @@ -409,13 +409,12 @@ func (r *Reflector) parseParametersIn( return nil } - defNamePrefix := strings.Title(string(in)) - definitionsPrefix := componentsSchemas + defNamePrefix + definitionsPrefix := componentsSchemas s, err := r.Reflect(input, openapi.WithOperationCtx(oc, false, in), jsonschema.DefinitionsPrefix(definitionsPrefix), - jsonschema.CollectDefinitions(r.collectDefinition(defNamePrefix)), + jsonschema.CollectDefinitions(r.collectDefinition()), jsonschema.PropertyNameMapping(propertyMapping), jsonschema.PropertyNameTag(string(in), additionalTags...), func(rc *jsonschema.ReflectContext) { @@ -464,7 +463,7 @@ func (r *Reflector) parseParametersIn( propertySchema, err := r.Reflect(property, openapi.WithOperationCtx(oc, false, in), jsonschema.DefinitionsPrefix(definitionsPrefix), - jsonschema.CollectDefinitions(r.collectDefinition(defNamePrefix)), + jsonschema.CollectDefinitions(r.collectDefinition()), jsonschema.RootRef, sanitizeDefName, ) @@ -542,10 +541,8 @@ func sanitizeDefName(rc *jsonschema.ReflectContext) { })(rc) } -func (r *Reflector) collectDefinition(namePrefix string) func(name string, schema jsonschema.Schema) { +func (r *Reflector) collectDefinition() func(name string, schema jsonschema.Schema) { return func(name string, schema jsonschema.Schema) { - name = namePrefix + name - if _, exists := r.SpecEns().ComponentsEns().Schemas[name]; exists { return } @@ -742,7 +739,7 @@ func (r *Reflector) parseJSONResponse(resp *Response, oc openapi.OperationContex openapi.WithOperationCtx(oc, true, openapi.InBody), jsonschema.RootRef, jsonschema.DefinitionsPrefix(componentsSchemas), - jsonschema.CollectDefinitions(r.collectDefinition("")), + jsonschema.CollectDefinitions(r.collectDefinition()), sanitizeDefName, ) if err != nil { diff --git a/openapi31/reflect_test.go b/openapi31/reflect_test.go index 5413579..1fd82fd 100644 --- a/openapi31/reflect_test.go +++ b/openapi31/reflect_test.go @@ -543,8 +543,9 @@ func TestReflector_AddOperation_request_queryNamedObject(t *testing.T) { "post":{ "parameters":[ { - "name":"in_query","in":"query","style":"deepObject","explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi31TestLabels"} + "name":"in_query","in":"query", + "schema":{"$ref":"#/components/schemas/Openapi31TestLabels"}, + "style":"deepObject","explode":true } ], "responses":{"204":{"description":"No Content"}} @@ -553,12 +554,12 @@ func TestReflector_AddOperation_request_queryNamedObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi31TestLabels":{"type":"object","additionalProperties":{"type":"number"}} + "Openapi31TestLabels":{"additionalProperties":{"type":"number"},"type":"object"} } } }`, s) - js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/QueryOpenapi31TestLabels") + js, found := reflector.ResolveJSONSchemaRef("#/components/schemas/Openapi31TestLabels") assert.True(t, found) assertjson.EqMarshal(t, `{"type":"object","additionalProperties":{"type":"number"}}`, js) } @@ -592,17 +593,13 @@ func TestReflector_AddOperation_request_jsonQuery(t *testing.T) { { "name":"one","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi31TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestFilter"}} } }, { "name":"two","in":"query", "content":{ - "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi31TestFilter"} - } + "application/json":{"schema":{"$ref":"#/components/schemas/Openapi31TestFilter"}} } }, { @@ -620,7 +617,7 @@ func TestReflector_AddOperation_request_jsonQuery(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi31TestFilter":{ + "Openapi31TestFilter":{ "properties":{ "labels":{"items":{"type":"string"},"type":"array"}, "type":{"type":"string"} @@ -980,18 +977,18 @@ func TestReflector_AddOperation_request_queryObject_deepObject(t *testing.T) { "name":"json_filter","in":"query", "content":{ "application/json":{ - "schema":{"$ref":"#/components/schemas/QueryOpenapi31TestJsonFilter"} + "schema":{"$ref":"#/components/schemas/Openapi31TestJsonFilter"} } } }, { - "name":"deep_object_filter","in":"query","style":"deepObject", - "explode":true, - "schema":{"$ref":"#/components/schemas/QueryOpenapi31TestDeepObjectFilter"} + "name":"deep_object_filter","in":"query", + "schema":{"$ref":"#/components/schemas/Openapi31TestDeepObjectFilter"}, + "style":"deepObject","explode":true }, { "name":"id","in":"path","required":true, - "schema":{"type":"string","examples":["XXX-XXXXX"]} + "schema":{"examples":["XXX-XXXXX"],"type":"string"} } ], "responses":{"204":{"description":"No Content"}} @@ -1000,21 +997,21 @@ func TestReflector_AddOperation_request_queryObject_deepObject(t *testing.T) { }, "components":{ "schemas":{ - "QueryOpenapi31TestDeepObjectFilter":{ - "type":"object", + "Openapi31TestDeepObjectFilter":{ "properties":{ "baz":{"type":"boolean"}, - "deeper":{"type":"object","properties":{"val":{"type":"string"}}}, + "deeper":{"properties":{"val":{"type":"string"}},"type":"object"}, "quux":{"type":"number"} - } + }, + "type":"object" }, - "QueryOpenapi31TestJsonFilter":{ - "type":"object", + "Openapi31TestJsonFilter":{ "properties":{ "bar":{"type":"integer"}, - "deeper":{"type":"object","properties":{"val":{"type":"string"}}}, + "deeper":{"properties":{"val":{"type":"string"}},"type":"object"}, "foo":{"type":"string"} - } + }, + "type":"object" } } }