diff --git a/litestar/_openapi/schema_generation/schema.py b/litestar/_openapi/schema_generation/schema.py index faba560043..891ace9c43 100644 --- a/litestar/_openapi/schema_generation/schema.py +++ b/litestar/_openapi/schema_generation/schema.py @@ -117,7 +117,7 @@ Sequence: Schema(type=OpenAPIType.ARRAY), Set: Schema(type=OpenAPIType.ARRAY), Tuple: Schema(type=OpenAPIType.ARRAY), - UUID: Schema(type=OpenAPIType.STRING, format=OpenAPIFormat.UUID, description="Any UUID string"), + UUID: Schema(type=OpenAPIType.STRING, format=OpenAPIFormat.UUID), bool: Schema(type=OpenAPIType.BOOLEAN), bytearray: Schema(type=OpenAPIType.STRING), bytes: Schema(type=OpenAPIType.STRING), diff --git a/tests/examples/test_openapi.py b/tests/examples/test_openapi.py index 22dd6dec4d..e83dd1f41d 100644 --- a/tests/examples/test_openapi.py +++ b/tests/examples/test_openapi.py @@ -28,7 +28,7 @@ def test_schema_generation() -> None: "components": { "schemas": { "IdModel": { - "properties": {"id": {"type": "string", "format": "uuid", "description": "Any UUID string"}}, + "properties": {"id": {"type": "string", "format": "uuid"}}, "type": "object", "required": ["id"], "title": "IdContainer", diff --git a/tests/unit/test_openapi/test_parameters.py b/tests/unit/test_openapi/test_parameters.py index 6c01b47f80..6439322883 100644 --- a/tests/unit/test_openapi/test_parameters.py +++ b/tests/unit/test_openapi/test_parameters.py @@ -1,4 +1,5 @@ from typing import TYPE_CHECKING, List, Optional, Type, cast +from uuid import UUID import pytest from typing_extensions import Annotated @@ -324,3 +325,21 @@ async def index( assert response.json()["paths"]["/"]["get"]["parameters"][0]["examples"] == { "text-example-1": {"summary": "example summary", "value": "example value"} } + + +def test_uuid_path_description_generation() -> None: + # https://github.com/litestar-org/litestar/issues/2967 + @get("str/{id:str}") + async def str_path(id: Annotated[str, Parameter(description="String ID")]) -> str: + return id + + @get("uuid/{id:uuid}") + async def uuid_path(id: Annotated[UUID, Parameter(description="UUID ID")]) -> UUID: + return id + + with create_test_client( + [str_path, uuid_path], openapi_config=OpenAPIConfig(title="Test API", version="1.0.0") + ) as client: + response = client.get("/schema/openapi.json") + assert response.json()["paths"]["/str/{id}"]["get"]["parameters"][0]["description"] == "String ID" + assert response.json()["paths"]["/uuid/{id}"]["get"]["parameters"][0]["description"] == "UUID ID"