class TestController(Controller):
path = "/test"
@post(
path="/route",
summary="Test Route",
tags=["Test"],
responses={503: ResponseSpec(data_container=ServiceUnavailableModel, description="Device or service unavailable")},
)
async def test_route(self, data: SomeDataModel) -> SomeResponseModel:
return {"test": data}
The responses= line causes this error.
Steps to reproduce
No response
Screenshots
No response
Logs
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/litestar/middleware/exceptions/middleware.py", line 149, in __call__
await self.app(scope, receive, send)
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 77, in handle
response = await self._get_response_for_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 129, in _get_response_for_request
response = await self._call_handler_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 158, in _call_handler_function
response_data, cleanup_group = await self._get_response_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/routes/http.py", line 210, in _get_response_data
data = route_handler.fn.value(**parsed_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 221, in root
return Response(content=render_method(request), media_type=MediaType.HTML)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 397, in render_redoc
schema = self.get_schema_from_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/openapi/controller.py", line 105, in get_schema_from_request
return request.app.openapi_schema
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 510, in openapi_schema
self.update_openapi_schema()
File "/usr/local/lib/python3.11/site-packages/litestar/app.py", line 825, in update_openapi_schema
path_item, created_operation_ids = create_path_item(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/path_item.py", line 125, in create_path_item
responses=create_responses(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/responses.py", line 259, in create_responses
for status_code, response in create_additional_responses(
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/responses.py", line 226, in create_additional_responses
schema = create_schema(
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 724, in create_schema
result = create_schema_for_pydantic_model(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 541, in create_schema_for_pydantic_model
properties={
^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 542, in <dictcomp>
(f.alias or f.name): create_schema(
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 769, in create_schema
return _process_schema_result(field=field, schema=result, generate_examples=generate_examples, schemas=schemas)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/schema.py", line 680, in _process_schema_result
schema.examples = create_examples_for_field(field=field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/examples.py", line 60, in create_examples_for_field
field_meta = _create_field_meta(field)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/litestar/_openapi/schema_generation/examples.py", line 41, in _create_field_meta
return FieldMeta(
^^^^^^^^^^
TypeError: FieldMeta.__init__() got an unexpected keyword argument 'constant'
Litestar Version
Litestar 2.0.0a4
polyfactory 2.0.0alpha1 (no error)
polyfactory 2.0.0 (error)
Platform
[ ] Linux
[ ] Mac
[ ] Windows
[X] Other (Please specify in the description above)
Description
After going from
polyfactory==2.0.0alpha1
=>2.0.0
I end up withFieldMeta.__init__() got an unexpected keyword argument 'constant'
Looks like the example generation for the openapi docs is broken because the
constant
boolean field is removed from 2.0.0https://github.com/litestar-org/polyfactory/blob/v2.0.0/polyfactory/field_meta.py#L39-L48 (2.0.0)
vs
https://github.com/litestar-org/polyfactory/blob/v2.0.0alpha1/polyfactory/field_meta.py#L12-L21 (2.0.0a1)
And is set by https://github.com/litestar-org/litestar/blob/v2.0.0alpha4/litestar/_openapi/schema_generation/examples.py#L44 (2.0.0a4)
Running on docker
python:3.11-alpine
URL to code causing the issue
No response
MCVE
The
responses=
line causes this error.Steps to reproduce
No response
Screenshots
No response
Logs
Litestar Version
Litestar 2.0.0a4 polyfactory 2.0.0alpha1 (no error) polyfactory 2.0.0 (error)
Platform