Coverage for tests/test_response_model_as_return_annotation.py: 100%
281 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from typing import List, Union 1abcde
3import pytest 1abcde
4from fastapi import FastAPI 1abcde
5from fastapi.exceptions import FastAPIError, ResponseValidationError 1abcde
6from fastapi.responses import JSONResponse, Response 1abcde
7from fastapi.testclient import TestClient 1abcde
8from pydantic import BaseModel 1abcde
11class BaseUser(BaseModel): 1abcde
12 name: str 1abcde
15class User(BaseUser): 1abcde
16 surname: str 1abcde
19class DBUser(User): 1abcde
20 password_hash: str 1abcde
23class Item(BaseModel): 1abcde
24 name: str 1abcde
25 price: float 1abcde
28app = FastAPI() 1abcde
31@app.get("/no_response_model-no_annotation-return_model") 1abcde
32def no_response_model_no_annotation_return_model(): 1abcde
33 return User(name="John", surname="Doe") 1abcde
36@app.get("/no_response_model-no_annotation-return_dict") 1abcde
37def no_response_model_no_annotation_return_dict(): 1abcde
38 return {"name": "John", "surname": "Doe"} 1abcde
41@app.get("/response_model-no_annotation-return_same_model", response_model=User) 1abcde
42def response_model_no_annotation_return_same_model(): 1abcde
43 return User(name="John", surname="Doe") 1abcde
46@app.get("/response_model-no_annotation-return_exact_dict", response_model=User) 1abcde
47def response_model_no_annotation_return_exact_dict(): 1abcde
48 return {"name": "John", "surname": "Doe"} 1abcde
51@app.get("/response_model-no_annotation-return_invalid_dict", response_model=User) 1abcde
52def response_model_no_annotation_return_invalid_dict(): 1abcde
53 return {"name": "John"} 1abcde
56@app.get("/response_model-no_annotation-return_invalid_model", response_model=User) 1abcde
57def response_model_no_annotation_return_invalid_model(): 1abcde
58 return Item(name="Foo", price=42.0) 1abcde
61@app.get( 1abcde
62 "/response_model-no_annotation-return_dict_with_extra_data", response_model=User
63)
64def response_model_no_annotation_return_dict_with_extra_data(): 1abcde
65 return {"name": "John", "surname": "Doe", "password_hash": "secret"} 1abcde
68@app.get( 1abcde
69 "/response_model-no_annotation-return_submodel_with_extra_data", response_model=User
70)
71def response_model_no_annotation_return_submodel_with_extra_data(): 1abcde
72 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
75@app.get("/no_response_model-annotation-return_same_model") 1abcde
76def no_response_model_annotation_return_same_model() -> User: 1abcde
77 return User(name="John", surname="Doe") 1abcde
80@app.get("/no_response_model-annotation-return_exact_dict") 1abcde
81def no_response_model_annotation_return_exact_dict() -> User: 1abcde
82 return {"name": "John", "surname": "Doe"} 1abcde
85@app.get("/no_response_model-annotation-return_invalid_dict") 1abcde
86def no_response_model_annotation_return_invalid_dict() -> User: 1abcde
87 return {"name": "John"} 1abcde
90@app.get("/no_response_model-annotation-return_invalid_model") 1abcde
91def no_response_model_annotation_return_invalid_model() -> User: 1abcde
92 return Item(name="Foo", price=42.0) 1abcde
95@app.get("/no_response_model-annotation-return_dict_with_extra_data") 1abcde
96def no_response_model_annotation_return_dict_with_extra_data() -> User: 1abcde
97 return {"name": "John", "surname": "Doe", "password_hash": "secret"} 1abcde
100@app.get("/no_response_model-annotation-return_submodel_with_extra_data") 1abcde
101def no_response_model_annotation_return_submodel_with_extra_data() -> User: 1abcde
102 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
105@app.get("/response_model_none-annotation-return_same_model", response_model=None) 1abcde
106def response_model_none_annotation_return_same_model() -> User: 1abcde
107 return User(name="John", surname="Doe") 1abcde
110@app.get("/response_model_none-annotation-return_exact_dict", response_model=None) 1abcde
111def response_model_none_annotation_return_exact_dict() -> User: 1abcde
112 return {"name": "John", "surname": "Doe"} 1abcde
115@app.get("/response_model_none-annotation-return_invalid_dict", response_model=None) 1abcde
116def response_model_none_annotation_return_invalid_dict() -> User: 1abcde
117 return {"name": "John"} 1abcde
120@app.get("/response_model_none-annotation-return_invalid_model", response_model=None) 1abcde
121def response_model_none_annotation_return_invalid_model() -> User: 1abcde
122 return Item(name="Foo", price=42.0) 1abcde
125@app.get( 1abcde
126 "/response_model_none-annotation-return_dict_with_extra_data", response_model=None
127)
128def response_model_none_annotation_return_dict_with_extra_data() -> User: 1abcde
129 return {"name": "John", "surname": "Doe", "password_hash": "secret"} 1abcde
132@app.get( 1abcde
133 "/response_model_none-annotation-return_submodel_with_extra_data",
134 response_model=None,
135)
136def response_model_none_annotation_return_submodel_with_extra_data() -> User: 1abcde
137 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
140@app.get( 1abcde
141 "/response_model_model1-annotation_model2-return_same_model", response_model=User
142)
143def response_model_model1_annotation_model2_return_same_model() -> Item: 1abcde
144 return User(name="John", surname="Doe") 1abcde
147@app.get( 1abcde
148 "/response_model_model1-annotation_model2-return_exact_dict", response_model=User
149)
150def response_model_model1_annotation_model2_return_exact_dict() -> Item: 1abcde
151 return {"name": "John", "surname": "Doe"} 1abcde
154@app.get( 1abcde
155 "/response_model_model1-annotation_model2-return_invalid_dict", response_model=User
156)
157def response_model_model1_annotation_model2_return_invalid_dict() -> Item: 1abcde
158 return {"name": "John"} 1abcde
161@app.get( 1abcde
162 "/response_model_model1-annotation_model2-return_invalid_model", response_model=User
163)
164def response_model_model1_annotation_model2_return_invalid_model() -> Item: 1abcde
165 return Item(name="Foo", price=42.0) 1abcde
168@app.get( 1abcde
169 "/response_model_model1-annotation_model2-return_dict_with_extra_data",
170 response_model=User,
171)
172def response_model_model1_annotation_model2_return_dict_with_extra_data() -> Item: 1abcde
173 return {"name": "John", "surname": "Doe", "password_hash": "secret"} 1abcde
176@app.get( 1abcde
177 "/response_model_model1-annotation_model2-return_submodel_with_extra_data",
178 response_model=User,
179)
180def response_model_model1_annotation_model2_return_submodel_with_extra_data() -> Item: 1abcde
181 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
184@app.get( 1abcde
185 "/response_model_filtering_model-annotation_submodel-return_submodel",
186 response_model=User,
187)
188def response_model_filtering_model_annotation_submodel_return_submodel() -> DBUser: 1abcde
189 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
192@app.get("/response_model_list_of_model-no_annotation", response_model=List[User]) 1abcde
193def response_model_list_of_model_no_annotation(): 1abcde
194 return [ 1abcde
195 DBUser(name="John", surname="Doe", password_hash="secret"),
196 DBUser(name="Jane", surname="Does", password_hash="secret2"),
197 ]
200@app.get("/no_response_model-annotation_list_of_model") 1abcde
201def no_response_model_annotation_list_of_model() -> List[User]: 1abcde
202 return [ 1abcde
203 DBUser(name="John", surname="Doe", password_hash="secret"),
204 DBUser(name="Jane", surname="Does", password_hash="secret2"),
205 ]
208@app.get("/no_response_model-annotation_forward_ref_list_of_model") 1abcde
209def no_response_model_annotation_forward_ref_list_of_model() -> "List[User]": 1abcde
210 return [ 1abcde
211 DBUser(name="John", surname="Doe", password_hash="secret"),
212 DBUser(name="Jane", surname="Does", password_hash="secret2"),
213 ]
216@app.get( 1abcde
217 "/response_model_union-no_annotation-return_model1",
218 response_model=Union[User, Item],
219)
220def response_model_union_no_annotation_return_model1(): 1abcde
221 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
224@app.get( 1abcde
225 "/response_model_union-no_annotation-return_model2",
226 response_model=Union[User, Item],
227)
228def response_model_union_no_annotation_return_model2(): 1abcde
229 return Item(name="Foo", price=42.0) 1abcde
232@app.get("/no_response_model-annotation_union-return_model1") 1abcde
233def no_response_model_annotation_union_return_model1() -> Union[User, Item]: 1abcde
234 return DBUser(name="John", surname="Doe", password_hash="secret") 1abcde
237@app.get("/no_response_model-annotation_union-return_model2") 1abcde
238def no_response_model_annotation_union_return_model2() -> Union[User, Item]: 1abcde
239 return Item(name="Foo", price=42.0) 1abcde
242@app.get("/no_response_model-annotation_response_class") 1abcde
243def no_response_model_annotation_response_class() -> Response: 1abcde
244 return Response(content="Foo") 1abcde
247@app.get("/no_response_model-annotation_json_response_class") 1abcde
248def no_response_model_annotation_json_response_class() -> JSONResponse: 1abcde
249 return JSONResponse(content={"foo": "bar"}) 1abcde
252client = TestClient(app) 1abcde
255def test_no_response_model_no_annotation_return_model(): 1abcde
256 response = client.get("/no_response_model-no_annotation-return_model") 1abcde
257 assert response.status_code == 200, response.text 1abcde
258 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
261def test_no_response_model_no_annotation_return_dict(): 1abcde
262 response = client.get("/no_response_model-no_annotation-return_dict") 1abcde
263 assert response.status_code == 200, response.text 1abcde
264 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
267def test_response_model_no_annotation_return_same_model(): 1abcde
268 response = client.get("/response_model-no_annotation-return_same_model") 1abcde
269 assert response.status_code == 200, response.text 1abcde
270 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
273def test_response_model_no_annotation_return_exact_dict(): 1abcde
274 response = client.get("/response_model-no_annotation-return_exact_dict") 1abcde
275 assert response.status_code == 200, response.text 1abcde
276 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
279def test_response_model_no_annotation_return_invalid_dict(): 1abcde
280 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
281 client.get("/response_model-no_annotation-return_invalid_dict") 1abcde
282 assert "missing" in str(excinfo.value) 1abcde
285def test_response_model_no_annotation_return_invalid_model(): 1abcde
286 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
287 client.get("/response_model-no_annotation-return_invalid_model") 1abcde
288 assert "missing" in str(excinfo.value) 1abcde
291def test_response_model_no_annotation_return_dict_with_extra_data(): 1abcde
292 response = client.get("/response_model-no_annotation-return_dict_with_extra_data") 1abcde
293 assert response.status_code == 200, response.text 1abcde
294 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
297def test_response_model_no_annotation_return_submodel_with_extra_data(): 1abcde
298 response = client.get( 1abcde
299 "/response_model-no_annotation-return_submodel_with_extra_data"
300 )
301 assert response.status_code == 200, response.text 1abcde
302 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
305def test_no_response_model_annotation_return_same_model(): 1abcde
306 response = client.get("/no_response_model-annotation-return_same_model") 1abcde
307 assert response.status_code == 200, response.text 1abcde
308 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
311def test_no_response_model_annotation_return_exact_dict(): 1abcde
312 response = client.get("/no_response_model-annotation-return_exact_dict") 1abcde
313 assert response.status_code == 200, response.text 1abcde
314 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
317def test_no_response_model_annotation_return_invalid_dict(): 1abcde
318 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
319 client.get("/no_response_model-annotation-return_invalid_dict") 1abcde
320 assert "missing" in str(excinfo.value) 1abcde
323def test_no_response_model_annotation_return_invalid_model(): 1abcde
324 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
325 client.get("/no_response_model-annotation-return_invalid_model") 1abcde
326 assert "missing" in str(excinfo.value) 1abcde
329def test_no_response_model_annotation_return_dict_with_extra_data(): 1abcde
330 response = client.get("/no_response_model-annotation-return_dict_with_extra_data") 1abcde
331 assert response.status_code == 200, response.text 1abcde
332 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
335def test_no_response_model_annotation_return_submodel_with_extra_data(): 1abcde
336 response = client.get( 1abcde
337 "/no_response_model-annotation-return_submodel_with_extra_data"
338 )
339 assert response.status_code == 200, response.text 1abcde
340 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
343def test_response_model_none_annotation_return_same_model(): 1abcde
344 response = client.get("/response_model_none-annotation-return_same_model") 1abcde
345 assert response.status_code == 200, response.text 1abcde
346 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
349def test_response_model_none_annotation_return_exact_dict(): 1abcde
350 response = client.get("/response_model_none-annotation-return_exact_dict") 1abcde
351 assert response.status_code == 200, response.text 1abcde
352 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
355def test_response_model_none_annotation_return_invalid_dict(): 1abcde
356 response = client.get("/response_model_none-annotation-return_invalid_dict") 1abcde
357 assert response.status_code == 200, response.text 1abcde
358 assert response.json() == {"name": "John"} 1abcde
361def test_response_model_none_annotation_return_invalid_model(): 1abcde
362 response = client.get("/response_model_none-annotation-return_invalid_model") 1abcde
363 assert response.status_code == 200, response.text 1abcde
364 assert response.json() == {"name": "Foo", "price": 42.0} 1abcde
367def test_response_model_none_annotation_return_dict_with_extra_data(): 1abcde
368 response = client.get("/response_model_none-annotation-return_dict_with_extra_data") 1abcde
369 assert response.status_code == 200, response.text 1abcde
370 assert response.json() == { 1abcde
371 "name": "John",
372 "surname": "Doe",
373 "password_hash": "secret",
374 }
377def test_response_model_none_annotation_return_submodel_with_extra_data(): 1abcde
378 response = client.get( 1abcde
379 "/response_model_none-annotation-return_submodel_with_extra_data"
380 )
381 assert response.status_code == 200, response.text 1abcde
382 assert response.json() == { 1abcde
383 "name": "John",
384 "surname": "Doe",
385 "password_hash": "secret",
386 }
389def test_response_model_model1_annotation_model2_return_same_model(): 1abcde
390 response = client.get("/response_model_model1-annotation_model2-return_same_model") 1abcde
391 assert response.status_code == 200, response.text 1abcde
392 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
395def test_response_model_model1_annotation_model2_return_exact_dict(): 1abcde
396 response = client.get("/response_model_model1-annotation_model2-return_exact_dict") 1abcde
397 assert response.status_code == 200, response.text 1abcde
398 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
401def test_response_model_model1_annotation_model2_return_invalid_dict(): 1abcde
402 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
403 client.get("/response_model_model1-annotation_model2-return_invalid_dict") 1abcde
404 assert "missing" in str(excinfo.value) 1abcde
407def test_response_model_model1_annotation_model2_return_invalid_model(): 1abcde
408 with pytest.raises(ResponseValidationError) as excinfo: 1abcde
409 client.get("/response_model_model1-annotation_model2-return_invalid_model") 1abcde
410 assert "missing" in str(excinfo.value) 1abcde
413def test_response_model_model1_annotation_model2_return_dict_with_extra_data(): 1abcde
414 response = client.get( 1abcde
415 "/response_model_model1-annotation_model2-return_dict_with_extra_data"
416 )
417 assert response.status_code == 200, response.text 1abcde
418 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
421def test_response_model_model1_annotation_model2_return_submodel_with_extra_data(): 1abcde
422 response = client.get( 1abcde
423 "/response_model_model1-annotation_model2-return_submodel_with_extra_data"
424 )
425 assert response.status_code == 200, response.text 1abcde
426 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
429def test_response_model_filtering_model_annotation_submodel_return_submodel(): 1abcde
430 response = client.get( 1abcde
431 "/response_model_filtering_model-annotation_submodel-return_submodel"
432 )
433 assert response.status_code == 200, response.text 1abcde
434 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
437def test_response_model_list_of_model_no_annotation(): 1abcde
438 response = client.get("/response_model_list_of_model-no_annotation") 1abcde
439 assert response.status_code == 200, response.text 1abcde
440 assert response.json() == [ 1abcde
441 {"name": "John", "surname": "Doe"},
442 {"name": "Jane", "surname": "Does"},
443 ]
446def test_no_response_model_annotation_list_of_model(): 1abcde
447 response = client.get("/no_response_model-annotation_list_of_model") 1abcde
448 assert response.status_code == 200, response.text 1abcde
449 assert response.json() == [ 1abcde
450 {"name": "John", "surname": "Doe"},
451 {"name": "Jane", "surname": "Does"},
452 ]
455def test_no_response_model_annotation_forward_ref_list_of_model(): 1abcde
456 response = client.get("/no_response_model-annotation_forward_ref_list_of_model") 1abcde
457 assert response.status_code == 200, response.text 1abcde
458 assert response.json() == [ 1abcde
459 {"name": "John", "surname": "Doe"},
460 {"name": "Jane", "surname": "Does"},
461 ]
464def test_response_model_union_no_annotation_return_model1(): 1abcde
465 response = client.get("/response_model_union-no_annotation-return_model1") 1abcde
466 assert response.status_code == 200, response.text 1abcde
467 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
470def test_response_model_union_no_annotation_return_model2(): 1abcde
471 response = client.get("/response_model_union-no_annotation-return_model2") 1abcde
472 assert response.status_code == 200, response.text 1abcde
473 assert response.json() == {"name": "Foo", "price": 42.0} 1abcde
476def test_no_response_model_annotation_union_return_model1(): 1abcde
477 response = client.get("/no_response_model-annotation_union-return_model1") 1abcde
478 assert response.status_code == 200, response.text 1abcde
479 assert response.json() == {"name": "John", "surname": "Doe"} 1abcde
482def test_no_response_model_annotation_union_return_model2(): 1abcde
483 response = client.get("/no_response_model-annotation_union-return_model2") 1abcde
484 assert response.status_code == 200, response.text 1abcde
485 assert response.json() == {"name": "Foo", "price": 42.0} 1abcde
488def test_no_response_model_annotation_return_class(): 1abcde
489 response = client.get("/no_response_model-annotation_response_class") 1abcde
490 assert response.status_code == 200, response.text 1abcde
491 assert response.text == "Foo" 1abcde
494def test_no_response_model_annotation_json_response_class(): 1abcde
495 response = client.get("/no_response_model-annotation_json_response_class") 1abcde
496 assert response.status_code == 200, response.text 1abcde
497 assert response.json() == {"foo": "bar"} 1abcde
500def test_invalid_response_model_field(): 1abcde
501 app = FastAPI() 1abcde
502 with pytest.raises(FastAPIError) as e: 1abcde
504 @app.get("/") 1abcde
505 def read_root() -> Union[Response, None]: 1abcde
506 return Response(content="Foo") # pragma: no cover
508 assert "valid Pydantic field type" in e.value.args[0] 1abcde
509 assert "parameter response_model=None" in e.value.args[0] 1abcde
512def test_openapi_schema(): 1abcde
513 response = client.get("/openapi.json") 1abcde
514 assert response.status_code == 200, response.text 1abcde
515 assert response.json() == { 1abcde
516 "openapi": "3.1.0",
517 "info": {"title": "FastAPI", "version": "0.1.0"},
518 "paths": {
519 "/no_response_model-no_annotation-return_model": {
520 "get": {
521 "summary": "No Response Model No Annotation Return Model",
522 "operationId": "no_response_model_no_annotation_return_model_no_response_model_no_annotation_return_model_get",
523 "responses": {
524 "200": {
525 "description": "Successful Response",
526 "content": {"application/json": {"schema": {}}},
527 }
528 },
529 }
530 },
531 "/no_response_model-no_annotation-return_dict": {
532 "get": {
533 "summary": "No Response Model No Annotation Return Dict",
534 "operationId": "no_response_model_no_annotation_return_dict_no_response_model_no_annotation_return_dict_get",
535 "responses": {
536 "200": {
537 "description": "Successful Response",
538 "content": {"application/json": {"schema": {}}},
539 }
540 },
541 }
542 },
543 "/response_model-no_annotation-return_same_model": {
544 "get": {
545 "summary": "Response Model No Annotation Return Same Model",
546 "operationId": "response_model_no_annotation_return_same_model_response_model_no_annotation_return_same_model_get",
547 "responses": {
548 "200": {
549 "description": "Successful Response",
550 "content": {
551 "application/json": {
552 "schema": {"$ref": "#/components/schemas/User"}
553 }
554 },
555 }
556 },
557 }
558 },
559 "/response_model-no_annotation-return_exact_dict": {
560 "get": {
561 "summary": "Response Model No Annotation Return Exact Dict",
562 "operationId": "response_model_no_annotation_return_exact_dict_response_model_no_annotation_return_exact_dict_get",
563 "responses": {
564 "200": {
565 "description": "Successful Response",
566 "content": {
567 "application/json": {
568 "schema": {"$ref": "#/components/schemas/User"}
569 }
570 },
571 }
572 },
573 }
574 },
575 "/response_model-no_annotation-return_invalid_dict": {
576 "get": {
577 "summary": "Response Model No Annotation Return Invalid Dict",
578 "operationId": "response_model_no_annotation_return_invalid_dict_response_model_no_annotation_return_invalid_dict_get",
579 "responses": {
580 "200": {
581 "description": "Successful Response",
582 "content": {
583 "application/json": {
584 "schema": {"$ref": "#/components/schemas/User"}
585 }
586 },
587 }
588 },
589 }
590 },
591 "/response_model-no_annotation-return_invalid_model": {
592 "get": {
593 "summary": "Response Model No Annotation Return Invalid Model",
594 "operationId": "response_model_no_annotation_return_invalid_model_response_model_no_annotation_return_invalid_model_get",
595 "responses": {
596 "200": {
597 "description": "Successful Response",
598 "content": {
599 "application/json": {
600 "schema": {"$ref": "#/components/schemas/User"}
601 }
602 },
603 }
604 },
605 }
606 },
607 "/response_model-no_annotation-return_dict_with_extra_data": {
608 "get": {
609 "summary": "Response Model No Annotation Return Dict With Extra Data",
610 "operationId": "response_model_no_annotation_return_dict_with_extra_data_response_model_no_annotation_return_dict_with_extra_data_get",
611 "responses": {
612 "200": {
613 "description": "Successful Response",
614 "content": {
615 "application/json": {
616 "schema": {"$ref": "#/components/schemas/User"}
617 }
618 },
619 }
620 },
621 }
622 },
623 "/response_model-no_annotation-return_submodel_with_extra_data": {
624 "get": {
625 "summary": "Response Model No Annotation Return Submodel With Extra Data",
626 "operationId": "response_model_no_annotation_return_submodel_with_extra_data_response_model_no_annotation_return_submodel_with_extra_data_get",
627 "responses": {
628 "200": {
629 "description": "Successful Response",
630 "content": {
631 "application/json": {
632 "schema": {"$ref": "#/components/schemas/User"}
633 }
634 },
635 }
636 },
637 }
638 },
639 "/no_response_model-annotation-return_same_model": {
640 "get": {
641 "summary": "No Response Model Annotation Return Same Model",
642 "operationId": "no_response_model_annotation_return_same_model_no_response_model_annotation_return_same_model_get",
643 "responses": {
644 "200": {
645 "description": "Successful Response",
646 "content": {
647 "application/json": {
648 "schema": {"$ref": "#/components/schemas/User"}
649 }
650 },
651 }
652 },
653 }
654 },
655 "/no_response_model-annotation-return_exact_dict": {
656 "get": {
657 "summary": "No Response Model Annotation Return Exact Dict",
658 "operationId": "no_response_model_annotation_return_exact_dict_no_response_model_annotation_return_exact_dict_get",
659 "responses": {
660 "200": {
661 "description": "Successful Response",
662 "content": {
663 "application/json": {
664 "schema": {"$ref": "#/components/schemas/User"}
665 }
666 },
667 }
668 },
669 }
670 },
671 "/no_response_model-annotation-return_invalid_dict": {
672 "get": {
673 "summary": "No Response Model Annotation Return Invalid Dict",
674 "operationId": "no_response_model_annotation_return_invalid_dict_no_response_model_annotation_return_invalid_dict_get",
675 "responses": {
676 "200": {
677 "description": "Successful Response",
678 "content": {
679 "application/json": {
680 "schema": {"$ref": "#/components/schemas/User"}
681 }
682 },
683 }
684 },
685 }
686 },
687 "/no_response_model-annotation-return_invalid_model": {
688 "get": {
689 "summary": "No Response Model Annotation Return Invalid Model",
690 "operationId": "no_response_model_annotation_return_invalid_model_no_response_model_annotation_return_invalid_model_get",
691 "responses": {
692 "200": {
693 "description": "Successful Response",
694 "content": {
695 "application/json": {
696 "schema": {"$ref": "#/components/schemas/User"}
697 }
698 },
699 }
700 },
701 }
702 },
703 "/no_response_model-annotation-return_dict_with_extra_data": {
704 "get": {
705 "summary": "No Response Model Annotation Return Dict With Extra Data",
706 "operationId": "no_response_model_annotation_return_dict_with_extra_data_no_response_model_annotation_return_dict_with_extra_data_get",
707 "responses": {
708 "200": {
709 "description": "Successful Response",
710 "content": {
711 "application/json": {
712 "schema": {"$ref": "#/components/schemas/User"}
713 }
714 },
715 }
716 },
717 }
718 },
719 "/no_response_model-annotation-return_submodel_with_extra_data": {
720 "get": {
721 "summary": "No Response Model Annotation Return Submodel With Extra Data",
722 "operationId": "no_response_model_annotation_return_submodel_with_extra_data_no_response_model_annotation_return_submodel_with_extra_data_get",
723 "responses": {
724 "200": {
725 "description": "Successful Response",
726 "content": {
727 "application/json": {
728 "schema": {"$ref": "#/components/schemas/User"}
729 }
730 },
731 }
732 },
733 }
734 },
735 "/response_model_none-annotation-return_same_model": {
736 "get": {
737 "summary": "Response Model None Annotation Return Same Model",
738 "operationId": "response_model_none_annotation_return_same_model_response_model_none_annotation_return_same_model_get",
739 "responses": {
740 "200": {
741 "description": "Successful Response",
742 "content": {"application/json": {"schema": {}}},
743 }
744 },
745 }
746 },
747 "/response_model_none-annotation-return_exact_dict": {
748 "get": {
749 "summary": "Response Model None Annotation Return Exact Dict",
750 "operationId": "response_model_none_annotation_return_exact_dict_response_model_none_annotation_return_exact_dict_get",
751 "responses": {
752 "200": {
753 "description": "Successful Response",
754 "content": {"application/json": {"schema": {}}},
755 }
756 },
757 }
758 },
759 "/response_model_none-annotation-return_invalid_dict": {
760 "get": {
761 "summary": "Response Model None Annotation Return Invalid Dict",
762 "operationId": "response_model_none_annotation_return_invalid_dict_response_model_none_annotation_return_invalid_dict_get",
763 "responses": {
764 "200": {
765 "description": "Successful Response",
766 "content": {"application/json": {"schema": {}}},
767 }
768 },
769 }
770 },
771 "/response_model_none-annotation-return_invalid_model": {
772 "get": {
773 "summary": "Response Model None Annotation Return Invalid Model",
774 "operationId": "response_model_none_annotation_return_invalid_model_response_model_none_annotation_return_invalid_model_get",
775 "responses": {
776 "200": {
777 "description": "Successful Response",
778 "content": {"application/json": {"schema": {}}},
779 }
780 },
781 }
782 },
783 "/response_model_none-annotation-return_dict_with_extra_data": {
784 "get": {
785 "summary": "Response Model None Annotation Return Dict With Extra Data",
786 "operationId": "response_model_none_annotation_return_dict_with_extra_data_response_model_none_annotation_return_dict_with_extra_data_get",
787 "responses": {
788 "200": {
789 "description": "Successful Response",
790 "content": {"application/json": {"schema": {}}},
791 }
792 },
793 }
794 },
795 "/response_model_none-annotation-return_submodel_with_extra_data": {
796 "get": {
797 "summary": "Response Model None Annotation Return Submodel With Extra Data",
798 "operationId": "response_model_none_annotation_return_submodel_with_extra_data_response_model_none_annotation_return_submodel_with_extra_data_get",
799 "responses": {
800 "200": {
801 "description": "Successful Response",
802 "content": {"application/json": {"schema": {}}},
803 }
804 },
805 }
806 },
807 "/response_model_model1-annotation_model2-return_same_model": {
808 "get": {
809 "summary": "Response Model Model1 Annotation Model2 Return Same Model",
810 "operationId": "response_model_model1_annotation_model2_return_same_model_response_model_model1_annotation_model2_return_same_model_get",
811 "responses": {
812 "200": {
813 "description": "Successful Response",
814 "content": {
815 "application/json": {
816 "schema": {"$ref": "#/components/schemas/User"}
817 }
818 },
819 }
820 },
821 }
822 },
823 "/response_model_model1-annotation_model2-return_exact_dict": {
824 "get": {
825 "summary": "Response Model Model1 Annotation Model2 Return Exact Dict",
826 "operationId": "response_model_model1_annotation_model2_return_exact_dict_response_model_model1_annotation_model2_return_exact_dict_get",
827 "responses": {
828 "200": {
829 "description": "Successful Response",
830 "content": {
831 "application/json": {
832 "schema": {"$ref": "#/components/schemas/User"}
833 }
834 },
835 }
836 },
837 }
838 },
839 "/response_model_model1-annotation_model2-return_invalid_dict": {
840 "get": {
841 "summary": "Response Model Model1 Annotation Model2 Return Invalid Dict",
842 "operationId": "response_model_model1_annotation_model2_return_invalid_dict_response_model_model1_annotation_model2_return_invalid_dict_get",
843 "responses": {
844 "200": {
845 "description": "Successful Response",
846 "content": {
847 "application/json": {
848 "schema": {"$ref": "#/components/schemas/User"}
849 }
850 },
851 }
852 },
853 }
854 },
855 "/response_model_model1-annotation_model2-return_invalid_model": {
856 "get": {
857 "summary": "Response Model Model1 Annotation Model2 Return Invalid Model",
858 "operationId": "response_model_model1_annotation_model2_return_invalid_model_response_model_model1_annotation_model2_return_invalid_model_get",
859 "responses": {
860 "200": {
861 "description": "Successful Response",
862 "content": {
863 "application/json": {
864 "schema": {"$ref": "#/components/schemas/User"}
865 }
866 },
867 }
868 },
869 }
870 },
871 "/response_model_model1-annotation_model2-return_dict_with_extra_data": {
872 "get": {
873 "summary": "Response Model Model1 Annotation Model2 Return Dict With Extra Data",
874 "operationId": "response_model_model1_annotation_model2_return_dict_with_extra_data_response_model_model1_annotation_model2_return_dict_with_extra_data_get",
875 "responses": {
876 "200": {
877 "description": "Successful Response",
878 "content": {
879 "application/json": {
880 "schema": {"$ref": "#/components/schemas/User"}
881 }
882 },
883 }
884 },
885 }
886 },
887 "/response_model_model1-annotation_model2-return_submodel_with_extra_data": {
888 "get": {
889 "summary": "Response Model Model1 Annotation Model2 Return Submodel With Extra Data",
890 "operationId": "response_model_model1_annotation_model2_return_submodel_with_extra_data_response_model_model1_annotation_model2_return_submodel_with_extra_data_get",
891 "responses": {
892 "200": {
893 "description": "Successful Response",
894 "content": {
895 "application/json": {
896 "schema": {"$ref": "#/components/schemas/User"}
897 }
898 },
899 }
900 },
901 }
902 },
903 "/response_model_filtering_model-annotation_submodel-return_submodel": {
904 "get": {
905 "summary": "Response Model Filtering Model Annotation Submodel Return Submodel",
906 "operationId": "response_model_filtering_model_annotation_submodel_return_submodel_response_model_filtering_model_annotation_submodel_return_submodel_get",
907 "responses": {
908 "200": {
909 "description": "Successful Response",
910 "content": {
911 "application/json": {
912 "schema": {"$ref": "#/components/schemas/User"}
913 }
914 },
915 }
916 },
917 }
918 },
919 "/response_model_list_of_model-no_annotation": {
920 "get": {
921 "summary": "Response Model List Of Model No Annotation",
922 "operationId": "response_model_list_of_model_no_annotation_response_model_list_of_model_no_annotation_get",
923 "responses": {
924 "200": {
925 "description": "Successful Response",
926 "content": {
927 "application/json": {
928 "schema": {
929 "title": "Response Response Model List Of Model No Annotation Response Model List Of Model No Annotation Get",
930 "type": "array",
931 "items": {"$ref": "#/components/schemas/User"},
932 }
933 }
934 },
935 }
936 },
937 }
938 },
939 "/no_response_model-annotation_list_of_model": {
940 "get": {
941 "summary": "No Response Model Annotation List Of Model",
942 "operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get",
943 "responses": {
944 "200": {
945 "description": "Successful Response",
946 "content": {
947 "application/json": {
948 "schema": {
949 "title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get",
950 "type": "array",
951 "items": {"$ref": "#/components/schemas/User"},
952 }
953 }
954 },
955 }
956 },
957 }
958 },
959 "/no_response_model-annotation_forward_ref_list_of_model": {
960 "get": {
961 "summary": "No Response Model Annotation Forward Ref List Of Model",
962 "operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get",
963 "responses": {
964 "200": {
965 "description": "Successful Response",
966 "content": {
967 "application/json": {
968 "schema": {
969 "title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get",
970 "type": "array",
971 "items": {"$ref": "#/components/schemas/User"},
972 }
973 }
974 },
975 }
976 },
977 }
978 },
979 "/response_model_union-no_annotation-return_model1": {
980 "get": {
981 "summary": "Response Model Union No Annotation Return Model1",
982 "operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get",
983 "responses": {
984 "200": {
985 "description": "Successful Response",
986 "content": {
987 "application/json": {
988 "schema": {
989 "title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get",
990 "anyOf": [
991 {"$ref": "#/components/schemas/User"},
992 {"$ref": "#/components/schemas/Item"},
993 ],
994 }
995 }
996 },
997 }
998 },
999 }
1000 },
1001 "/response_model_union-no_annotation-return_model2": {
1002 "get": {
1003 "summary": "Response Model Union No Annotation Return Model2",
1004 "operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get",
1005 "responses": {
1006 "200": {
1007 "description": "Successful Response",
1008 "content": {
1009 "application/json": {
1010 "schema": {
1011 "title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get",
1012 "anyOf": [
1013 {"$ref": "#/components/schemas/User"},
1014 {"$ref": "#/components/schemas/Item"},
1015 ],
1016 }
1017 }
1018 },
1019 }
1020 },
1021 }
1022 },
1023 "/no_response_model-annotation_union-return_model1": {
1024 "get": {
1025 "summary": "No Response Model Annotation Union Return Model1",
1026 "operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get",
1027 "responses": {
1028 "200": {
1029 "description": "Successful Response",
1030 "content": {
1031 "application/json": {
1032 "schema": {
1033 "title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get",
1034 "anyOf": [
1035 {"$ref": "#/components/schemas/User"},
1036 {"$ref": "#/components/schemas/Item"},
1037 ],
1038 }
1039 }
1040 },
1041 }
1042 },
1043 }
1044 },
1045 "/no_response_model-annotation_union-return_model2": {
1046 "get": {
1047 "summary": "No Response Model Annotation Union Return Model2",
1048 "operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get",
1049 "responses": {
1050 "200": {
1051 "description": "Successful Response",
1052 "content": {
1053 "application/json": {
1054 "schema": {
1055 "title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get",
1056 "anyOf": [
1057 {"$ref": "#/components/schemas/User"},
1058 {"$ref": "#/components/schemas/Item"},
1059 ],
1060 }
1061 }
1062 },
1063 }
1064 },
1065 }
1066 },
1067 "/no_response_model-annotation_response_class": {
1068 "get": {
1069 "summary": "No Response Model Annotation Response Class",
1070 "operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get",
1071 "responses": {
1072 "200": {
1073 "description": "Successful Response",
1074 "content": {"application/json": {"schema": {}}},
1075 }
1076 },
1077 }
1078 },
1079 "/no_response_model-annotation_json_response_class": {
1080 "get": {
1081 "summary": "No Response Model Annotation Json Response Class",
1082 "operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get",
1083 "responses": {
1084 "200": {
1085 "description": "Successful Response",
1086 "content": {"application/json": {"schema": {}}},
1087 }
1088 },
1089 }
1090 },
1091 },
1092 "components": {
1093 "schemas": {
1094 "Item": {
1095 "title": "Item",
1096 "required": ["name", "price"],
1097 "type": "object",
1098 "properties": {
1099 "name": {"title": "Name", "type": "string"},
1100 "price": {"title": "Price", "type": "number"},
1101 },
1102 },
1103 "User": {
1104 "title": "User",
1105 "required": ["name", "surname"],
1106 "type": "object",
1107 "properties": {
1108 "name": {"title": "Name", "type": "string"},
1109 "surname": {"title": "Surname", "type": "string"},
1110 },
1111 },
1112 }
1113 },
1114 }