Repository: swaggest/openapi-go
Pull request #77 (2023-08-08 22:45:49)

Simplify definition names

github-actions[bot]: ### Lines Of Code

| Language  | Files |   Lines    |    Code    | Comments |  Blanks  | Complexity |     Bytes      |
|-----------|-------|------------|------------|----------|----------|------------|----------------|
| Go        | 20    | 3826 (-6)  | 2839 (-4)  | 214      | 773 (-2) | 791        | 88.5K (-266B)  |
| Go (test) | 18    | 5490 (-11) | 4093 (-11) | 660      | 737      | 55         | 143.9K (-263B) |
| JSON      | 16    | 5555 (-55) | 5555 (-55) | 0        | 0        | 0          | 133.6K (-576B) |
<!-- Sticky Pull Request CommentLOC -->
github-actions[bot]: ### Go API Changes

<pre>
# summary
Inferred base version: v0.2.38
Suggested version: v0.2.39
</pre>
<!-- Sticky Pull Request Commentgorelease -->
github-actions[bot]: ### Unit Test Coverage
total:									(statements)				39.7%
changed lines: (statements) 100.0%
<details><summary>Coverage of changed lines</summary>

|           File           |     Function      | Coverage |
|--------------------------|-------------------|----------|
| Total                    |                   | 100.0%   |
| openapi3/reflect.go      |                   | 100.0%   |
| openapi3/reflect.go:445  | parseParametersIn | 100.0%   |
| openapi3/reflect.go:590  | collectDefinition | 100.0%   |
| openapi3/reflect.go:767  | parseJSONResponse | 100.0%   |
| openapi31/reflect.go     |                   | 100.0%   |
| openapi31/reflect.go:398 | parseParametersIn | 100.0%   |
| openapi31/reflect.go:544 | collectDefinition | 100.0%   |
| openapi31/reflect.go:725 | parseJSONResponse | 100.0%   |

</details>

<details><summary>Coverage diff with base branch</summary>

|                        File                         |     Function      | Base Coverage | Current Coverage |
|-----------------------------------------------------|-------------------|---------------|------------------|
| Total                                               |                   | 39.7%         | 39.7% (0.0%)     |
| github.com/swaggest/openapi-go/openapi3/reflect.go  | parseParametersIn | 86.2%         | 86.0% (-0.2%)    |
| github.com/swaggest/openapi-go/openapi31/reflect.go | collectDefinition | 87.5%         | 85.7% (-1.8%)    |
| github.com/swaggest/openapi-go/openapi31/reflect.go | parseParametersIn | 82.8%         | 82.5% (-0.3%)    |

</details>
<!-- Sticky Pull Request Commentunit-test -->
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/swaggest/openapi-go/pull/77?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) Report
> Merging [#77](https://app.codecov.io/gh/swaggest/openapi-go/pull/77?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) (65df89a) into [master](https://app.codecov.io/gh/swaggest/openapi-go/commit/893f0c99a5ed877a94e8f66a87a5b494fd025de9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) (893f0c9) will **decrease** coverage by `0.04%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master      #77      +/-   ##
==========================================
- Coverage   35.64%   35.60%   -0.04%     
==========================================
  Files          14       14              
  Lines        6546     6542       -4     
==========================================
- Hits         2333     2329       -4     
  Misses       3828     3828              
  Partials      385      385              
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `35.60% <100.00%> (-0.04%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Files Changed](https://app.codecov.io/gh/swaggest/openapi-go/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) | Coverage Δ | |
|---|---|---|
| [openapi3/reflect.go](https://app.codecov.io/gh/swaggest/openapi-go/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest#diff-b3BlbmFwaTMvcmVmbGVjdC5nbw==) | `80.97% <100.00%> (-0.10%)` | :arrow_down: |
| [openapi31/reflect.go](https://app.codecov.io/gh/swaggest/openapi-go/pull/77?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest#diff-b3BlbmFwaTMxL3JlZmxlY3QuZ28=) | `74.41% <100.00%> (-0.14%)` | :arrow_down: |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest)


Patch:
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/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 {


Test patch:
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_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_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"
 		  }
 		}
 	  }