Skip to content

Commit 5f5e0a9

Browse files
committed
fixed openapi schema change
1 parent 3aa9019 commit 5f5e0a9

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

tests/test_openapi/test_builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ def test_builder_build_document_has_correct_schema():
234234
"parameters": [
235235
{
236236
"required": True,
237-
"schema_": {"title": "Cat Id", "type": "integer"},
237+
"schema_": {
238+
"title": "Cat Id",
239+
"type": "integer",
240+
"include_in_schema": True,
241+
},
238242
"name": "cat_id",
239243
"in_": "path",
240244
}

tests/test_openapi/test_open_api_route_documentation.py

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,29 @@ def test_open_api_route_get_openapi_operation_parameters_works_for_empty_model_n
120120
"name": "car_id",
121121
"in": "path",
122122
"required": True,
123-
"schema": {"title": "Car Id", "type": "integer"},
123+
"schema": {"title": "Car Id", "include_in_schema": True, "type": "integer"},
124124
},
125125
{
126126
"name": "to",
127127
"in": "query",
128128
"required": False,
129-
"schema": {"title": "To", "type": "string", "format": "date-time"},
129+
"schema": {
130+
"title": "To",
131+
"include_in_schema": True,
132+
"type": "string",
133+
"format": "date-time",
134+
},
130135
},
131136
{
132137
"name": "from",
133138
"in": "query",
134139
"required": False,
135-
"schema": {"title": "From", "type": "string", "format": "date-time"},
140+
"schema": {
141+
"title": "From",
142+
"include_in_schema": True,
143+
"type": "string",
144+
"format": "date-time",
145+
},
136146
},
137147
]
138148

@@ -161,12 +171,16 @@ def test_open_api_route_get_openapi_operation_request_body():
161171
model_name_map=model_name_map
162172
)
163173
assert result == {
164-
"required": True,
165174
"content": {
166175
"application/json": {
167-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
176+
"schema": {
177+
"allOf": [{"$ref": "#/components/schemas/CreateCarSchema"}],
178+
"include_in_schema": True,
179+
"title": "Car",
180+
}
168181
}
169182
},
183+
"required": True,
170184
}
171185

172186

@@ -190,7 +204,11 @@ def test_open_api_route_get_child_openapi_path():
190204
"required": True,
191205
"content": {
192206
"application/json": {
193-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
207+
"schema": {
208+
"title": "Car",
209+
"include_in_schema": True,
210+
"allOf": [{"$ref": "#/components/schemas/CreateCarSchema"}],
211+
}
194212
}
195213
},
196214
},
@@ -245,7 +263,13 @@ def test_open_api_route_get_openapi_path():
245263
"required": True,
246264
"content": {
247265
"application/json": {
248-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
266+
"schema": {
267+
"title": "Car",
268+
"include_in_schema": True,
269+
"allOf": [
270+
{"$ref": "#/components/schemas/CreateCarSchema"}
271+
],
272+
}
249273
}
250274
},
251275
},
@@ -295,7 +319,13 @@ def test_open_api_route_get_openapi_path():
295319
"required": True,
296320
"content": {
297321
"application/json": {
298-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
322+
"schema": {
323+
"title": "Car",
324+
"include_in_schema": True,
325+
"allOf": [
326+
{"$ref": "#/components/schemas/CreateCarSchema"}
327+
],
328+
}
299329
}
300330
},
301331
},
@@ -365,7 +395,13 @@ def test_open_api_route_get_openapi_path_with_security():
365395
"required": True,
366396
"content": {
367397
"application/json": {
368-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
398+
"schema": {
399+
"title": "Car",
400+
"include_in_schema": True,
401+
"allOf": [
402+
{"$ref": "#/components/schemas/CreateCarSchema"}
403+
],
404+
}
369405
}
370406
},
371407
},
@@ -412,13 +448,17 @@ def test_open_api_route__get_openapi_path_object_works_for_routes_with_multiple_
412448
result = openapi_route_doc._get_openapi_path_object(model_name_map=model_name_map)
413449
assert isinstance(result, tuple)
414450
assert result[0] == {
415-
"post": {
451+
"get": {
416452
"summary": None,
417-
"operationId": "list_and_create_car_list_post",
453+
"operationId": "list_and_create_car_list_get",
418454
"requestBody": {
419455
"content": {
420456
"application/json": {
421-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
457+
"schema": {
458+
"title": "Car",
459+
"include_in_schema": True,
460+
"allOf": [{"$ref": "#/components/schemas/CreateCarSchema"}],
461+
}
422462
}
423463
}
424464
},
@@ -444,13 +484,17 @@ def test_open_api_route__get_openapi_path_object_works_for_routes_with_multiple_
444484
},
445485
},
446486
},
447-
"get": {
487+
"post": {
448488
"summary": None,
449-
"operationId": "list_and_create_car_list_get",
489+
"operationId": "list_and_create_car_list_post",
450490
"requestBody": {
451491
"content": {
452492
"application/json": {
453-
"schema": {"$ref": "#/components/schemas/CreateCarSchema"}
493+
"schema": {
494+
"title": "Car",
495+
"include_in_schema": True,
496+
"allOf": [{"$ref": "#/components/schemas/CreateCarSchema"}],
497+
}
454498
}
455499
}
456500
},

0 commit comments

Comments
 (0)