diff --git a/tests/test_additional_responses.py b/tests/test_additional_responses.py index ddd5b7664..aa18dfbc6 100644 --- a/tests/test_additional_responses.py +++ b/tests/test_additional_responses.py @@ -1,3 +1,4 @@ +import pytest from fastapi import FastAPI from fastapi.openapi.models import AdditionalResponse from pydantic import BaseModel @@ -409,6 +410,19 @@ openapi_schema = { } +def test_uncompatible_response_model_undecorated(): + app = FastAPI() + + class NotBaseModel: + pass + + response_403 = AdditionalResponse( + status_code=403, description="Forbidden", models=[NotBaseModel] + ) + with pytest.raises(ValueError): + app.add_api_route("/", get_not_decorated, additional_responses=[response_403]) + + def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200