| 1 |
import pytest |
| 2 |
from fastapi import FastAPI |
| 3 |
from fastapi.exceptions import FastAPIError, ResponseValidationError |
| 4 |
from fastapi.responses import JSONResponse, Response |
| 5 |
from fastapi.testclient import TestClient |
| 6 |
from inline_snapshot import snapshot |
| 7 |
from pydantic import BaseModel |
| 8 |
|
| 9 |
|
| 10 |
class BaseUser(BaseModel): |
| 11 |
name: str |
| 12 |
|
| 13 |
|
| 14 |
class User(BaseUser): |
| 15 |
surname: str |
| 16 |
|
| 17 |
|
| 18 |
class DBUser(User): |
| 19 |
password_hash: str |
| 20 |
|
| 21 |
|
| 22 |
class Item(BaseModel): |
| 23 |
name: str |
| 24 |
price: float |
| 25 |
|
| 26 |
|
| 27 |
app = FastAPI() |
| 28 |
|
| 29 |
|
| 30 |
@app.get("/no_response_model-no_annotation-return_model") |
| 31 |
def no_response_model_no_annotation_return_model(): |
| 32 |
return User(name="John", surname="Doe") |
| 33 |
|
| 34 |
|
| 35 |
@app.get("/no_response_model-no_annotation-return_dict") |
| 36 |
def no_response_model_no_annotation_return_dict(): |
| 37 |
return {"name": "John", "surname": "Doe"} |
| 38 |
|
| 39 |
|
| 40 |
@app.get("/response_model-no_annotation-return_same_model", response_model=User) |
| 41 |
def response_model_no_annotation_return_same_model(): |
| 42 |
return User(name="John", surname="Doe") |
| 43 |
|
| 44 |
|
| 45 |
@app.get("/response_model-no_annotation-return_exact_dict", response_model=User) |
| 46 |
def response_model_no_annotation_return_exact_dict(): |
| 47 |
return {"name": "John", "surname": "Doe"} |
| 48 |
|
| 49 |
|
| 50 |
@app.get("/response_model-no_annotation-return_invalid_dict", response_model=User) |
| 51 |
def response_model_no_annotation_return_invalid_dict(): |
| 52 |
return {"name": "John"} |
| 53 |
|
| 54 |
|
| 55 |
@app.get("/response_model-no_annotation-return_invalid_model", response_model=User) |
| 56 |
def response_model_no_annotation_return_invalid_model(): |
| 57 |
return Item(name="Foo", price=42.0) |
| 58 |
|
| 59 |
|
| 60 |
@app.get( |
| 61 |
"/response_model-no_annotation-return_dict_with_extra_data", response_model=User |
| 62 |
) |
| 63 |
def response_model_no_annotation_return_dict_with_extra_data(): |
| 64 |
return {"name": "John", "surname": "Doe", "password_hash": "secret"} |
| 65 |
|
| 66 |
|
| 67 |
@app.get( |
| 68 |
"/response_model-no_annotation-return_submodel_with_extra_data", response_model=User |
| 69 |
) |
| 70 |
def response_model_no_annotation_return_submodel_with_extra_data(): |
| 71 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 72 |
|
| 73 |
|
| 74 |
@app.get("/no_response_model-annotation-return_same_model") |
| 75 |
def no_response_model_annotation_return_same_model() -> User: |
| 76 |
return User(name="John", surname="Doe") |
| 77 |
|
| 78 |
|
| 79 |
@app.get("/no_response_model-annotation-return_exact_dict") |
| 80 |
def no_response_model_annotation_return_exact_dict() -> User: |
| 81 |
return {"name": "John", "surname": "Doe"} # ty: ignore[invalid-return-type] |
| 82 |
|
| 83 |
|
| 84 |
@app.get("/no_response_model-annotation-return_invalid_dict") |
| 85 |
def no_response_model_annotation_return_invalid_dict() -> User: |
| 86 |
return {"name": "John"} # ty: ignore[invalid-return-type] |
| 87 |
|
| 88 |
|
| 89 |
@app.get("/no_response_model-annotation-return_invalid_model") |
| 90 |
def no_response_model_annotation_return_invalid_model() -> User: |
| 91 |
return Item(name="Foo", price=42.0) # ty: ignore[invalid-return-type] |
| 92 |
|
| 93 |
|
| 94 |
@app.get("/no_response_model-annotation-return_dict_with_extra_data") |
| 95 |
def no_response_model_annotation_return_dict_with_extra_data() -> User: |
| 96 |
return {"name": "John", "surname": "Doe", "password_hash": "secret"} # ty: ignore[invalid-return-type] |
| 97 |
|
| 98 |
|
| 99 |
@app.get("/no_response_model-annotation-return_submodel_with_extra_data") |
| 100 |
def no_response_model_annotation_return_submodel_with_extra_data() -> User: |
| 101 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 102 |
|
| 103 |
|
| 104 |
@app.get("/response_model_none-annotation-return_same_model", response_model=None) |
| 105 |
def response_model_none_annotation_return_same_model() -> User: |
| 106 |
return User(name="John", surname="Doe") |
| 107 |
|
| 108 |
|
| 109 |
@app.get("/response_model_none-annotation-return_exact_dict", response_model=None) |
| 110 |
def response_model_none_annotation_return_exact_dict() -> User: |
| 111 |
return {"name": "John", "surname": "Doe"} # ty: ignore[invalid-return-type] |
| 112 |
|
| 113 |
|
| 114 |
@app.get("/response_model_none-annotation-return_invalid_dict", response_model=None) |
| 115 |
def response_model_none_annotation_return_invalid_dict() -> User: |
| 116 |
return {"name": "John"} # ty: ignore[invalid-return-type] |
| 117 |
|
| 118 |
|
| 119 |
@app.get("/response_model_none-annotation-return_invalid_model", response_model=None) |
| 120 |
def response_model_none_annotation_return_invalid_model() -> User: |
| 121 |
return Item(name="Foo", price=42.0) # ty: ignore[invalid-return-type] |
| 122 |
|
| 123 |
|
| 124 |
@app.get( |
| 125 |
"/response_model_none-annotation-return_dict_with_extra_data", response_model=None |
| 126 |
) |
| 127 |
def response_model_none_annotation_return_dict_with_extra_data() -> User: |
| 128 |
return {"name": "John", "surname": "Doe", "password_hash": "secret"} # ty: ignore[invalid-return-type] |
| 129 |
|
| 130 |
|
| 131 |
@app.get( |
| 132 |
"/response_model_none-annotation-return_submodel_with_extra_data", |
| 133 |
response_model=None, |
| 134 |
) |
| 135 |
def response_model_none_annotation_return_submodel_with_extra_data() -> User: |
| 136 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 137 |
|
| 138 |
|
| 139 |
@app.get( |
| 140 |
"/response_model_model1-annotation_model2-return_same_model", response_model=User |
| 141 |
) |
| 142 |
def response_model_model1_annotation_model2_return_same_model() -> Item: |
| 143 |
return User(name="John", surname="Doe") # ty: ignore[invalid-return-type] |
| 144 |
|
| 145 |
|
| 146 |
@app.get( |
| 147 |
"/response_model_model1-annotation_model2-return_exact_dict", response_model=User |
| 148 |
) |
| 149 |
def response_model_model1_annotation_model2_return_exact_dict() -> Item: |
| 150 |
return {"name": "John", "surname": "Doe"} # ty: ignore[invalid-return-type] |
| 151 |
|
| 152 |
|
| 153 |
@app.get( |
| 154 |
"/response_model_model1-annotation_model2-return_invalid_dict", response_model=User |
| 155 |
) |
| 156 |
def response_model_model1_annotation_model2_return_invalid_dict() -> Item: |
| 157 |
return {"name": "John"} # ty: ignore[invalid-return-type] |
| 158 |
|
| 159 |
|
| 160 |
@app.get( |
| 161 |
"/response_model_model1-annotation_model2-return_invalid_model", response_model=User |
| 162 |
) |
| 163 |
def response_model_model1_annotation_model2_return_invalid_model() -> Item: |
| 164 |
return Item(name="Foo", price=42.0) |
| 165 |
|
| 166 |
|
| 167 |
@app.get( |
| 168 |
"/response_model_model1-annotation_model2-return_dict_with_extra_data", |
| 169 |
response_model=User, |
| 170 |
) |
| 171 |
def response_model_model1_annotation_model2_return_dict_with_extra_data() -> Item: |
| 172 |
return {"name": "John", "surname": "Doe", "password_hash": "secret"} # ty: ignore[invalid-return-type] |
| 173 |
|
| 174 |
|
| 175 |
@app.get( |
| 176 |
"/response_model_model1-annotation_model2-return_submodel_with_extra_data", |
| 177 |
response_model=User, |
| 178 |
) |
| 179 |
def response_model_model1_annotation_model2_return_submodel_with_extra_data() -> Item: |
| 180 |
return DBUser(name="John", surname="Doe", password_hash="secret") # ty: ignore[invalid-return-type] |
| 181 |
|
| 182 |
|
| 183 |
@app.get( |
| 184 |
"/response_model_filtering_model-annotation_submodel-return_submodel", |
| 185 |
response_model=User, |
| 186 |
) |
| 187 |
def response_model_filtering_model_annotation_submodel_return_submodel() -> DBUser: |
| 188 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 189 |
|
| 190 |
|
| 191 |
@app.get("/response_model_list_of_model-no_annotation", response_model=list[User]) |
| 192 |
def response_model_list_of_model_no_annotation(): |
| 193 |
return [ |
| 194 |
DBUser(name="John", surname="Doe", password_hash="secret"), |
| 195 |
DBUser(name="Jane", surname="Does", password_hash="secret2"), |
| 196 |
] |
| 197 |
|
| 198 |
|
| 199 |
@app.get("/no_response_model-annotation_list_of_model") |
| 200 |
def no_response_model_annotation_list_of_model() -> list[User]: |
| 201 |
return [ |
| 202 |
DBUser(name="John", surname="Doe", password_hash="secret"), |
| 203 |
DBUser(name="Jane", surname="Does", password_hash="secret2"), |
| 204 |
] |
| 205 |
|
| 206 |
|
| 207 |
@app.get("/no_response_model-annotation_forward_ref_list_of_model") |
| 208 |
def no_response_model_annotation_forward_ref_list_of_model() -> "list[User]": |
| 209 |
return [ |
| 210 |
DBUser(name="John", surname="Doe", password_hash="secret"), |
| 211 |
DBUser(name="Jane", surname="Does", password_hash="secret2"), |
| 212 |
] |
| 213 |
|
| 214 |
|
| 215 |
@app.get( |
| 216 |
"/response_model_union-no_annotation-return_model1", |
| 217 |
response_model=User | Item, |
| 218 |
) |
| 219 |
def response_model_union_no_annotation_return_model1(): |
| 220 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 221 |
|
| 222 |
|
| 223 |
@app.get( |
| 224 |
"/response_model_union-no_annotation-return_model2", |
| 225 |
response_model=User | Item, |
| 226 |
) |
| 227 |
def response_model_union_no_annotation_return_model2(): |
| 228 |
return Item(name="Foo", price=42.0) |
| 229 |
|
| 230 |
|
| 231 |
@app.get("/no_response_model-annotation_union-return_model1") |
| 232 |
def no_response_model_annotation_union_return_model1() -> User | Item: |
| 233 |
return DBUser(name="John", surname="Doe", password_hash="secret") |
| 234 |
|
| 235 |
|
| 236 |
@app.get("/no_response_model-annotation_union-return_model2") |
| 237 |
def no_response_model_annotation_union_return_model2() -> User | Item: |
| 238 |
return Item(name="Foo", price=42.0) |
| 239 |
|
| 240 |
|
| 241 |
@app.get("/no_response_model-annotation_response_class") |
| 242 |
def no_response_model_annotation_response_class() -> Response: |
| 243 |
return Response(content="Foo") |
| 244 |
|
| 245 |
|
| 246 |
@app.get("/no_response_model-annotation_json_response_class") |
| 247 |
def no_response_model_annotation_json_response_class() -> JSONResponse: |
| 248 |
return JSONResponse(content={"foo": "bar"}) |
| 249 |
|
| 250 |
|
| 251 |
client = TestClient(app) |
| 252 |
|
| 253 |
|
| 254 |
def test_no_response_model_no_annotation_return_model(): |
| 255 |
response = client.get("/no_response_model-no_annotation-return_model") |
| 256 |
assert response.status_code == 200, response.text |
| 257 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 258 |
|
| 259 |
|
| 260 |
def test_no_response_model_no_annotation_return_dict(): |
| 261 |
response = client.get("/no_response_model-no_annotation-return_dict") |
| 262 |
assert response.status_code == 200, response.text |
| 263 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 264 |
|
| 265 |
|
| 266 |
def test_response_model_no_annotation_return_same_model(): |
| 267 |
response = client.get("/response_model-no_annotation-return_same_model") |
| 268 |
assert response.status_code == 200, response.text |
| 269 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 270 |
|
| 271 |
|
| 272 |
def test_response_model_no_annotation_return_exact_dict(): |
| 273 |
response = client.get("/response_model-no_annotation-return_exact_dict") |
| 274 |
assert response.status_code == 200, response.text |
| 275 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 276 |
|
| 277 |
|
| 278 |
def test_response_model_no_annotation_return_invalid_dict(): |
| 279 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 280 |
client.get("/response_model-no_annotation-return_invalid_dict") |
| 281 |
assert "missing" in str(excinfo.value) |
| 282 |
|
| 283 |
|
| 284 |
def test_response_model_no_annotation_return_invalid_model(): |
| 285 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 286 |
client.get("/response_model-no_annotation-return_invalid_model") |
| 287 |
assert "missing" in str(excinfo.value) |
| 288 |
|
| 289 |
|
| 290 |
def test_response_model_no_annotation_return_dict_with_extra_data(): |
| 291 |
response = client.get("/response_model-no_annotation-return_dict_with_extra_data") |
| 292 |
assert response.status_code == 200, response.text |
| 293 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 294 |
|
| 295 |
|
| 296 |
def test_response_model_no_annotation_return_submodel_with_extra_data(): |
| 297 |
response = client.get( |
| 298 |
"/response_model-no_annotation-return_submodel_with_extra_data" |
| 299 |
) |
| 300 |
assert response.status_code == 200, response.text |
| 301 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 302 |
|
| 303 |
|
| 304 |
def test_no_response_model_annotation_return_same_model(): |
| 305 |
response = client.get("/no_response_model-annotation-return_same_model") |
| 306 |
assert response.status_code == 200, response.text |
| 307 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 308 |
|
| 309 |
|
| 310 |
def test_no_response_model_annotation_return_exact_dict(): |
| 311 |
response = client.get("/no_response_model-annotation-return_exact_dict") |
| 312 |
assert response.status_code == 200, response.text |
| 313 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 314 |
|
| 315 |
|
| 316 |
def test_no_response_model_annotation_return_invalid_dict(): |
| 317 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 318 |
client.get("/no_response_model-annotation-return_invalid_dict") |
| 319 |
assert "missing" in str(excinfo.value) |
| 320 |
|
| 321 |
|
| 322 |
def test_no_response_model_annotation_return_invalid_model(): |
| 323 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 324 |
client.get("/no_response_model-annotation-return_invalid_model") |
| 325 |
assert "missing" in str(excinfo.value) |
| 326 |
|
| 327 |
|
| 328 |
def test_no_response_model_annotation_return_dict_with_extra_data(): |
| 329 |
response = client.get("/no_response_model-annotation-return_dict_with_extra_data") |
| 330 |
assert response.status_code == 200, response.text |
| 331 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 332 |
|
| 333 |
|
| 334 |
def test_no_response_model_annotation_return_submodel_with_extra_data(): |
| 335 |
response = client.get( |
| 336 |
"/no_response_model-annotation-return_submodel_with_extra_data" |
| 337 |
) |
| 338 |
assert response.status_code == 200, response.text |
| 339 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 340 |
|
| 341 |
|
| 342 |
def test_response_model_none_annotation_return_same_model(): |
| 343 |
response = client.get("/response_model_none-annotation-return_same_model") |
| 344 |
assert response.status_code == 200, response.text |
| 345 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 346 |
|
| 347 |
|
| 348 |
def test_response_model_none_annotation_return_exact_dict(): |
| 349 |
response = client.get("/response_model_none-annotation-return_exact_dict") |
| 350 |
assert response.status_code == 200, response.text |
| 351 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 352 |
|
| 353 |
|
| 354 |
def test_response_model_none_annotation_return_invalid_dict(): |
| 355 |
response = client.get("/response_model_none-annotation-return_invalid_dict") |
| 356 |
assert response.status_code == 200, response.text |
| 357 |
assert response.json() == {"name": "John"} |
| 358 |
|
| 359 |
|
| 360 |
def test_response_model_none_annotation_return_invalid_model(): |
| 361 |
response = client.get("/response_model_none-annotation-return_invalid_model") |
| 362 |
assert response.status_code == 200, response.text |
| 363 |
assert response.json() == {"name": "Foo", "price": 42.0} |
| 364 |
|
| 365 |
|
| 366 |
def test_response_model_none_annotation_return_dict_with_extra_data(): |
| 367 |
response = client.get("/response_model_none-annotation-return_dict_with_extra_data") |
| 368 |
assert response.status_code == 200, response.text |
| 369 |
assert response.json() == { |
| 370 |
"name": "John", |
| 371 |
"surname": "Doe", |
| 372 |
"password_hash": "secret", |
| 373 |
} |
| 374 |
|
| 375 |
|
| 376 |
def test_response_model_none_annotation_return_submodel_with_extra_data(): |
| 377 |
response = client.get( |
| 378 |
"/response_model_none-annotation-return_submodel_with_extra_data" |
| 379 |
) |
| 380 |
assert response.status_code == 200, response.text |
| 381 |
assert response.json() == { |
| 382 |
"name": "John", |
| 383 |
"surname": "Doe", |
| 384 |
"password_hash": "secret", |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
def test_response_model_model1_annotation_model2_return_same_model(): |
| 389 |
response = client.get("/response_model_model1-annotation_model2-return_same_model") |
| 390 |
assert response.status_code == 200, response.text |
| 391 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 392 |
|
| 393 |
|
| 394 |
def test_response_model_model1_annotation_model2_return_exact_dict(): |
| 395 |
response = client.get("/response_model_model1-annotation_model2-return_exact_dict") |
| 396 |
assert response.status_code == 200, response.text |
| 397 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 398 |
|
| 399 |
|
| 400 |
def test_response_model_model1_annotation_model2_return_invalid_dict(): |
| 401 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 402 |
client.get("/response_model_model1-annotation_model2-return_invalid_dict") |
| 403 |
assert "missing" in str(excinfo.value) |
| 404 |
|
| 405 |
|
| 406 |
def test_response_model_model1_annotation_model2_return_invalid_model(): |
| 407 |
with pytest.raises(ResponseValidationError) as excinfo: |
| 408 |
client.get("/response_model_model1-annotation_model2-return_invalid_model") |
| 409 |
assert "missing" in str(excinfo.value) |
| 410 |
|
| 411 |
|
| 412 |
def test_response_model_model1_annotation_model2_return_dict_with_extra_data(): |
| 413 |
response = client.get( |
| 414 |
"/response_model_model1-annotation_model2-return_dict_with_extra_data" |
| 415 |
) |
| 416 |
assert response.status_code == 200, response.text |
| 417 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 418 |
|
| 419 |
|
| 420 |
def test_response_model_model1_annotation_model2_return_submodel_with_extra_data(): |
| 421 |
response = client.get( |
| 422 |
"/response_model_model1-annotation_model2-return_submodel_with_extra_data" |
| 423 |
) |
| 424 |
assert response.status_code == 200, response.text |
| 425 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 426 |
|
| 427 |
|
| 428 |
def test_response_model_filtering_model_annotation_submodel_return_submodel(): |
| 429 |
response = client.get( |
| 430 |
"/response_model_filtering_model-annotation_submodel-return_submodel" |
| 431 |
) |
| 432 |
assert response.status_code == 200, response.text |
| 433 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 434 |
|
| 435 |
|
| 436 |
def test_response_model_list_of_model_no_annotation(): |
| 437 |
response = client.get("/response_model_list_of_model-no_annotation") |
| 438 |
assert response.status_code == 200, response.text |
| 439 |
assert response.json() == [ |
| 440 |
{"name": "John", "surname": "Doe"}, |
| 441 |
{"name": "Jane", "surname": "Does"}, |
| 442 |
] |
| 443 |
|
| 444 |
|
| 445 |
def test_no_response_model_annotation_list_of_model(): |
| 446 |
response = client.get("/no_response_model-annotation_list_of_model") |
| 447 |
assert response.status_code == 200, response.text |
| 448 |
assert response.json() == [ |
| 449 |
{"name": "John", "surname": "Doe"}, |
| 450 |
{"name": "Jane", "surname": "Does"}, |
| 451 |
] |
| 452 |
|
| 453 |
|
| 454 |
def test_no_response_model_annotation_forward_ref_list_of_model(): |
| 455 |
response = client.get("/no_response_model-annotation_forward_ref_list_of_model") |
| 456 |
assert response.status_code == 200, response.text |
| 457 |
assert response.json() == [ |
| 458 |
{"name": "John", "surname": "Doe"}, |
| 459 |
{"name": "Jane", "surname": "Does"}, |
| 460 |
] |
| 461 |
|
| 462 |
|
| 463 |
def test_response_model_union_no_annotation_return_model1(): |
| 464 |
response = client.get("/response_model_union-no_annotation-return_model1") |
| 465 |
assert response.status_code == 200, response.text |
| 466 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 467 |
|
| 468 |
|
| 469 |
def test_response_model_union_no_annotation_return_model2(): |
| 470 |
response = client.get("/response_model_union-no_annotation-return_model2") |
| 471 |
assert response.status_code == 200, response.text |
| 472 |
assert response.json() == {"name": "Foo", "price": 42.0} |
| 473 |
|
| 474 |
|
| 475 |
def test_no_response_model_annotation_union_return_model1(): |
| 476 |
response = client.get("/no_response_model-annotation_union-return_model1") |
| 477 |
assert response.status_code == 200, response.text |
| 478 |
assert response.json() == {"name": "John", "surname": "Doe"} |
| 479 |
|
| 480 |
|
| 481 |
def test_no_response_model_annotation_union_return_model2(): |
| 482 |
response = client.get("/no_response_model-annotation_union-return_model2") |
| 483 |
assert response.status_code == 200, response.text |
| 484 |
assert response.json() == {"name": "Foo", "price": 42.0} |
| 485 |
|
| 486 |
|
| 487 |
def test_no_response_model_annotation_return_class(): |
| 488 |
response = client.get("/no_response_model-annotation_response_class") |
| 489 |
assert response.status_code == 200, response.text |
| 490 |
assert response.text == "Foo" |
| 491 |
|
| 492 |
|
| 493 |
def test_no_response_model_annotation_json_response_class(): |
| 494 |
response = client.get("/no_response_model-annotation_json_response_class") |
| 495 |
assert response.status_code == 200, response.text |
| 496 |
assert response.json() == {"foo": "bar"} |
| 497 |
|
| 498 |
|
| 499 |
def test_invalid_response_model_field(): |
| 500 |
app = FastAPI() |
| 501 |
with pytest.raises(FastAPIError) as e: |
| 502 |
|
| 503 |
@app.get("/") |
| 504 |
def read_root() -> Response | None: |
| 505 |
return Response(content="Foo") # pragma: no cover |
| 506 |
|
| 507 |
assert "valid Pydantic field type" in e.value.args[0] |
| 508 |
assert "parameter response_model=None" in e.value.args[0] |
| 509 |
|
| 510 |
|
| 511 |
def test_openapi_schema(): |
| 512 |
response = client.get("/openapi.json") |
| 513 |
assert response.status_code == 200, response.text |
| 514 |
assert response.json() == snapshot( |
| 515 |
{ |
| 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": { |
| 932 |
"$ref": "#/components/schemas/User" |
| 933 |
}, |
| 934 |
} |
| 935 |
} |
| 936 |
}, |
| 937 |
} |
| 938 |
}, |
| 939 |
} |
| 940 |
}, |
| 941 |
"/no_response_model-annotation_list_of_model": { |
| 942 |
"get": { |
| 943 |
"summary": "No Response Model Annotation List Of Model", |
| 944 |
"operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get", |
| 945 |
"responses": { |
| 946 |
"200": { |
| 947 |
"description": "Successful Response", |
| 948 |
"content": { |
| 949 |
"application/json": { |
| 950 |
"schema": { |
| 951 |
"title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get", |
| 952 |
"type": "array", |
| 953 |
"items": { |
| 954 |
"$ref": "#/components/schemas/User" |
| 955 |
}, |
| 956 |
} |
| 957 |
} |
| 958 |
}, |
| 959 |
} |
| 960 |
}, |
| 961 |
} |
| 962 |
}, |
| 963 |
"/no_response_model-annotation_forward_ref_list_of_model": { |
| 964 |
"get": { |
| 965 |
"summary": "No Response Model Annotation Forward Ref List Of Model", |
| 966 |
"operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get", |
| 967 |
"responses": { |
| 968 |
"200": { |
| 969 |
"description": "Successful Response", |
| 970 |
"content": { |
| 971 |
"application/json": { |
| 972 |
"schema": { |
| 973 |
"title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get", |
| 974 |
"type": "array", |
| 975 |
"items": { |
| 976 |
"$ref": "#/components/schemas/User" |
| 977 |
}, |
| 978 |
} |
| 979 |
} |
| 980 |
}, |
| 981 |
} |
| 982 |
}, |
| 983 |
} |
| 984 |
}, |
| 985 |
"/response_model_union-no_annotation-return_model1": { |
| 986 |
"get": { |
| 987 |
"summary": "Response Model Union No Annotation Return Model1", |
| 988 |
"operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get", |
| 989 |
"responses": { |
| 990 |
"200": { |
| 991 |
"description": "Successful Response", |
| 992 |
"content": { |
| 993 |
"application/json": { |
| 994 |
"schema": { |
| 995 |
"title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get", |
| 996 |
"anyOf": [ |
| 997 |
{"$ref": "#/components/schemas/User"}, |
| 998 |
{"$ref": "#/components/schemas/Item"}, |
| 999 |
], |
| 1000 |
} |
| 1001 |
} |
| 1002 |
}, |
| 1003 |
} |
| 1004 |
}, |
| 1005 |
} |
| 1006 |
}, |
| 1007 |
"/response_model_union-no_annotation-return_model2": { |
| 1008 |
"get": { |
| 1009 |
"summary": "Response Model Union No Annotation Return Model2", |
| 1010 |
"operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get", |
| 1011 |
"responses": { |
| 1012 |
"200": { |
| 1013 |
"description": "Successful Response", |
| 1014 |
"content": { |
| 1015 |
"application/json": { |
| 1016 |
"schema": { |
| 1017 |
"title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get", |
| 1018 |
"anyOf": [ |
| 1019 |
{"$ref": "#/components/schemas/User"}, |
| 1020 |
{"$ref": "#/components/schemas/Item"}, |
| 1021 |
], |
| 1022 |
} |
| 1023 |
} |
| 1024 |
}, |
| 1025 |
} |
| 1026 |
}, |
| 1027 |
} |
| 1028 |
}, |
| 1029 |
"/no_response_model-annotation_union-return_model1": { |
| 1030 |
"get": { |
| 1031 |
"summary": "No Response Model Annotation Union Return Model1", |
| 1032 |
"operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get", |
| 1033 |
"responses": { |
| 1034 |
"200": { |
| 1035 |
"description": "Successful Response", |
| 1036 |
"content": { |
| 1037 |
"application/json": { |
| 1038 |
"schema": { |
| 1039 |
"title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get", |
| 1040 |
"anyOf": [ |
| 1041 |
{"$ref": "#/components/schemas/User"}, |
| 1042 |
{"$ref": "#/components/schemas/Item"}, |
| 1043 |
], |
| 1044 |
} |
| 1045 |
} |
| 1046 |
}, |
| 1047 |
} |
| 1048 |
}, |
| 1049 |
} |
| 1050 |
}, |
| 1051 |
"/no_response_model-annotation_union-return_model2": { |
| 1052 |
"get": { |
| 1053 |
"summary": "No Response Model Annotation Union Return Model2", |
| 1054 |
"operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get", |
| 1055 |
"responses": { |
| 1056 |
"200": { |
| 1057 |
"description": "Successful Response", |
| 1058 |
"content": { |
| 1059 |
"application/json": { |
| 1060 |
"schema": { |
| 1061 |
"title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get", |
| 1062 |
"anyOf": [ |
| 1063 |
{"$ref": "#/components/schemas/User"}, |
| 1064 |
{"$ref": "#/components/schemas/Item"}, |
| 1065 |
], |
| 1066 |
} |
| 1067 |
} |
| 1068 |
}, |
| 1069 |
} |
| 1070 |
}, |
| 1071 |
} |
| 1072 |
}, |
| 1073 |
"/no_response_model-annotation_response_class": { |
| 1074 |
"get": { |
| 1075 |
"summary": "No Response Model Annotation Response Class", |
| 1076 |
"operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get", |
| 1077 |
"responses": { |
| 1078 |
"200": { |
| 1079 |
"description": "Successful Response", |
| 1080 |
"content": {"application/json": {"schema": {}}}, |
| 1081 |
} |
| 1082 |
}, |
| 1083 |
} |
| 1084 |
}, |
| 1085 |
"/no_response_model-annotation_json_response_class": { |
| 1086 |
"get": { |
| 1087 |
"summary": "No Response Model Annotation Json Response Class", |
| 1088 |
"operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get", |
| 1089 |
"responses": { |
| 1090 |
"200": { |
| 1091 |
"description": "Successful Response", |
| 1092 |
"content": {"application/json": {"schema": {}}}, |
| 1093 |
} |
| 1094 |
}, |
| 1095 |
} |
| 1096 |
}, |
| 1097 |
}, |
| 1098 |
"components": { |
| 1099 |
"schemas": { |
| 1100 |
"Item": { |
| 1101 |
"title": "Item", |
| 1102 |
"required": ["name", "price"], |
| 1103 |
"type": "object", |
| 1104 |
"properties": { |
| 1105 |
"name": {"title": "Name", "type": "string"}, |
| 1106 |
"price": {"title": "Price", "type": "number"}, |
| 1107 |
}, |
| 1108 |
}, |
| 1109 |
"User": { |
| 1110 |
"title": "User", |
| 1111 |
"required": ["name", "surname"], |
| 1112 |
"type": "object", |
| 1113 |
"properties": { |
| 1114 |
"name": {"title": "Name", "type": "string"}, |
| 1115 |
"surname": {"title": "Surname", "type": "string"}, |
| 1116 |
}, |
| 1117 |
}, |
| 1118 |
} |
| 1119 |
}, |
| 1120 |
} |
| 1121 |
) |