Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 26, 2024
1 parent 3b51e8d commit e14f272
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions integration_tests/base_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ async def async_dict_post():

# Body


class TestMyRequest(Body):
items: List[str]
numbers: list[int]
Expand All @@ -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
Expand Down
11 changes: 3 additions & 8 deletions robyn/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand Down

0 comments on commit e14f272

Please sign in to comment.