failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · fastapi/fastapi
🐛 Fix OpenAPI schema support for computed fields when using `separate_input_output_schemas=False` This demonstrates how the output schema differs when the FastAPI app runs with different values for `separate_input_output_schemas` - namely, the computed fields are omitted. Initially reported here: https://github.com/fastapi/fastapi/discussions/10342
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
.....F
=================================== FAILURES ===================================
__________________________ test_openapi_schema[False] __________________________
client = <starlette.testclient.TestClient object at 0x108940b90>
@pytest.mark.parametrize("client", [True, False], indirect=True)
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
> assert response.json() == {
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/": {
"get": {
"summary": "Read Root",
"operationId": "read_root__get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Rectangle"}
}
},
}
},
}
},
"/responses": {
"get": {
"summary": "Read Responses",
"operationId": "read_responses_responses_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Rectangle"}
}
},
}
},
}
},
},
"components": {
"schemas": {
"Rectangle": {
"properties": {
"width": {"type": "integer", "title": "Width"},
"length": {"type": "integer", "title": "Length"},
"area": {"type": "integer", "title": "Area", "readOnly": True},
},
"type": "object",
"required": ["width", "length", "area"],
"title": "Rectangle",
}
}
},
}
E AssertionError: assert {'openapi': '...Rectangle'}}}} == {'openapi': '...Rectangle'}}}}
E
E Omitting 3 identical items, use -vv to show
E Differing items:
E {'components': {'schemas': {'Rectangle': {'properties': {'width': {'type': 'integer', 'title': 'Width'}, 'length': {'type': 'integer', 'title': 'Length'}}, 'type': 'object', 'required': ['width', 'length'], 'title': 'Rectangle'}}}} != {'components': {'schemas': {'Rectangle': {'properties': {'width': {'type': 'integer', 'title': 'Width'}, 'length': {'t...title': 'Area', 'readOnly': True}}, 'type': 'object', 'required': ['width', 'length', 'area'], 'title': 'Rectangle'}}}}
E Use -v to get more diff
tests/test_computed_fields.py:50: AssertionError
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/overlays/starlette-0.50.0-py3-none-any/starlette/testclient.py:45: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.
_PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]]
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 5 passed, 1 warning in 0.67s