lqs
d20566fe07
Some checks failed
Test / lint (push) Has been cancelled
Test / test (pydantic-v1, 3.10) (push) Has been cancelled
Test / test (pydantic-v1, 3.11) (push) Has been cancelled
Test / test (pydantic-v1, 3.12) (push) Has been cancelled
Test / test (pydantic-v1, 3.8) (push) Has been cancelled
Test / test (pydantic-v1, 3.9) (push) Has been cancelled
Test / test (pydantic-v2, 3.10) (push) Has been cancelled
Test / test (pydantic-v2, 3.11) (push) Has been cancelled
Test / test (pydantic-v2, 3.12) (push) Has been cancelled
Test / test (pydantic-v2, 3.8) (push) Has been cancelled
Test / test (pydantic-v2, 3.9) (push) Has been cancelled
Test / coverage-combine (push) Has been cancelled
Test / check (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
Label Approved / label-approved (push) Has been cancelled
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import pytest
|
|
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/a", responses={"hello": {"description": "Not a valid additional response"}})
|
|
async def a():
|
|
pass # pragma: no cover
|
|
|
|
|
|
openapi_schema = {
|
|
"openapi": "3.1.0",
|
|
"info": {"title": "FastAPI", "version": "0.1.0"},
|
|
"paths": {
|
|
"/a": {
|
|
"get": {
|
|
"responses": {
|
|
# this is how one would imagine the openapi schema to be
|
|
# but since the key is not valid, openapi.utils.get_openapi will raise ValueError
|
|
"hello": {"description": "Not a valid additional response"},
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {"application/json": {"schema": {}}},
|
|
},
|
|
},
|
|
"summary": "A",
|
|
"operationId": "a_a_get",
|
|
}
|
|
}
|
|
},
|
|
}
|
|
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_openapi_schema():
|
|
with pytest.raises(ValueError):
|
|
client.get("/openapi.json")
|