Skip to content

Commit

Permalink
Lazy import model name formatter when we need it
Browse files Browse the repository at this point in the history
  • Loading branch information
cgearing committed Aug 11, 2024
1 parent 8d271e3 commit 36187dc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flask_pydantic_spec/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pydantic import BaseModel

from flask_pydantic_spec.constants import OPENAPI_SCHEMA_TEMPLATE
from flask_pydantic_spec.utils import get_model_name


class ResponseBase:
Expand Down Expand Up @@ -117,6 +116,7 @@ def generate_spec(self) -> Dict[str, Any]:

@staticmethod
def get_schema(model: Type[BaseModel], is_list: bool = False) -> Mapping[str, Any]:
from flask_pydantic_spec.utils import get_model_name
ref_schema = {"$ref": f"#/components/schemas/{get_model_name(model)}"}
if is_list:
return {"schema": {"type": "array", "items": ref_schema}}
Expand Down Expand Up @@ -172,6 +172,8 @@ def has_model(self) -> bool:
return self.model is not None

def generate_spec(self) -> Mapping[str, Any]:
from flask_pydantic_spec.utils import get_model_name

if self.content_type == "application/octet-stream":
return {
"content": {
Expand Down

0 comments on commit 36187dc

Please sign in to comment.