Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory Refactor #8

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ninja_schema/orm/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
from .model_schema import ModelSchema
from .schema import Schema

__all__ = [
"SchemaFactory",
]
__all__ = ["SchemaFactory"]


class SchemaFactory:
Expand All @@ -40,6 +38,7 @@ def create_schema(
fields: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
skip_registry: bool = False,
optional_fields: Optional[Union[str, List[str]]] = None,
) -> Union[Type["ModelSchema"], Type["Schema"], None]:
from .model_schema import ModelSchema

Expand All @@ -49,7 +48,7 @@ def create_schema(
raise ConfigError("Only one of 'include' or 'exclude' should be set.")

schema = registry.get_model_schema(model)
if schema:
if schema and not skip_registry:
return schema

model_config_kwargs = {
Expand All @@ -59,6 +58,7 @@ def create_schema(
"skip_registry": skip_registry,
"depth": depth,
"registry": registry,
"optional": optional_fields,
}
cls.get_model_config(**model_config_kwargs) # type: ignore
new_schema = (
Expand Down
Loading