You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a datetime.datetime (or datetime.date) is specified as the return type of an endpoint, there is an error during the generation of the OpenAPI documentation when the API starts up:
> run app.py
INFO:robyn.logger:SERVER IS RUNNING IN VERBOSE/DEBUG MODE. Set --log-level to WARN to run in production mode.
INFO:robyn.logger:Added route HttpMethod.POST /
Traceback (most recent call last):
File ".../bug_date_robyn/app.py", line 18, in <module>
app.start(host="0.0.0.0", port=8080)
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/__init__.py", line 308, in start
self._add_openapi_routes()
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/__init__.py", line 267, in _add_openapi_routes
self.router.prepare_routes_openapi(self.openapi, self.included_routers)
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/router.py", line 255, in prepare_routes_openapi
openapi.add_openapi_path_obj(lower_http_method(route.route_type), route.route, route.openapi_name, route.openapi_tags, route.function.handler)
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/openapi.py", line 215, in add_openapi_path_obj
modified_endpoint, path_obj = self.get_path_obj(
^^^^^^^^^^^^^^^^^^
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/openapi.py", line 341, in get_path_obj
response_schema = self.get_schema_object("response object", return_annotation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/openapi.py", line 408, in get_schema_object
properties["properties"][e] = self.get_schema_object(e, param_type.__annotations__[e])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../bug_date_robyn/.venv/lib/python3.12/site-packages/robyn/openapi.py", line 407, in get_schema_object
for e in param_type.__annotations__:
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'datetime.date' has no attribute '__annotations__'
Steps to Reproduce
Run Robyn with an endpoint that return a datetime:
- Add special handling for datetime.datetime and datetime.date types
- Add schema generation tests for datetime types
- Fix AttributeError when generating schema for datetime return types
Fixessparckles#1124
Bug Description
If a
datetime.datetime
(ordatetime.date
) is specified as the return type of an endpoint, there is an error during the generation of the OpenAPI documentation when the API starts up:Steps to Reproduce
Run Robyn with an endpoint that return a datetime:
app.py
:python app.py
It also poses a problem with
datetime.date
or with aJSONResponse
object encapsulating the field:Your operating system
Linux
Your Python version (
python --version
)3.12
Your Robyn version
latest
Additional Info
The text was updated successfully, but these errors were encountered: