Skip to content

Commit

Permalink
Merge branch 'sparckles:main' into mypy4
Browse files Browse the repository at this point in the history
  • Loading branch information
dave42w authored Nov 24, 2024
2 parents d29ba56 + a54c642 commit 47f48b1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions robyn/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
from robyn.types import Body


class str_typed_dict(TypedDict):
key: str
value: str


@dataclass
class Contact:
"""
Expand Down Expand Up @@ -236,9 +241,9 @@ def get_path_obj(
name: str,
description: str,
tags: List[str],
query_params: Optional[TypedDict],
request_body: Optional[TypedDict],
return_annotation: Optional[TypedDict],
query_params: Optional[str_typed_dict],
request_body: Optional[str_typed_dict],
return_annotation: Optional[str_typed_dict],
) -> Tuple[str, dict]:
"""
Get the "path" openapi object according to spec
Expand All @@ -258,7 +263,7 @@ def get_path_obj(
if not description:
description = "No description provided"

openapi_path_object = {
openapi_path_object: dict = {
"summary": name,
"description": description,
"parameters": [],
Expand Down Expand Up @@ -293,7 +298,7 @@ def get_path_obj(
endpoint_with_path_params_wrapped_in_braces += "/{" + path_param_name + "}"

if query_params:
query_param_annotations = query_params.__annotations__ if query_params is TypedDict else typing.get_type_hints(query_params)
query_param_annotations = query_params.__annotations__ if query_params is str_typed_dict else typing.get_type_hints(query_params)

for query_param in query_param_annotations:
query_param_type = self.get_openapi_type(query_param_annotations[query_param])
Expand Down Expand Up @@ -339,7 +344,7 @@ def get_path_obj(

return endpoint_with_path_params_wrapped_in_braces, openapi_path_object

def get_openapi_type(self, typed_dict: TypedDict) -> str:
def get_openapi_type(self, typed_dict: str_typed_dict) -> str:
"""
Get actual type from the TypedDict annotations
Expand Down Expand Up @@ -371,11 +376,11 @@ def get_schema_object(self, parameter: str, param_type: Any) -> dict:
@return: dict the properties object
"""

properties = {
properties: dict = {
"title": parameter.capitalize(),
}

type_mapping = {
type_mapping: dict = {
int: "integer",
str: "string",
bool: "boolean",
Expand Down

0 comments on commit 47f48b1

Please sign in to comment.