diff --git a/integration_tests/base_routes.py b/integration_tests/base_routes.py index 06898ddf..7cc35cd6 100644 --- a/integration_tests/base_routes.py +++ b/integration_tests/base_routes.py @@ -559,6 +559,7 @@ async def async_dict_post(): # Body + class TestMyRequest(Body): items: List[str] numbers: list[int] @@ -578,6 +579,7 @@ async def async_body_post(request: Request): def sync_form_data(request: Request): return request.headers["Content-Type"] + @app.post("/sync/body/typed") def sync_body_typed(body: TestMyRequest): # the server should just start diff --git a/robyn/openapi.py b/robyn/openapi.py index 92f9b03a..75dae7a6 100644 --- a/robyn/openapi.py +++ b/robyn/openapi.py @@ -403,12 +403,9 @@ def get_schema_object(self, parameter: str, param_type: Any) -> dict: # Handle Optional types if origin is Union and type(None) in args: non_none_type = next(t for t in args if t is not type(None)) - properties["anyOf"] = [ - {"type": self.get_openapi_type(non_none_type)}, - {"type": "null"} - ] + properties["anyOf"] = [{"type": self.get_openapi_type(non_none_type)}, {"type": "null"}] return properties - + # Handle List types elif origin in (list, List): properties["type"] = "array" @@ -424,9 +421,7 @@ def get_schema_object(self, parameter: str, param_type: Any) -> dict: if hasattr(param_type, "__annotations__"): for e in param_type.__annotations__: - properties["properties"][e] = self.get_schema_object( - e, param_type.__annotations__[e] - ) + properties["properties"][e] = self.get_schema_object(e, param_type.__annotations__[e]) return properties