Skip to content

Small change to Schema model to allow generated specs to be picklable #243

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

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion openapi_core/schema/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def __init__(

self._source = _source

# Overriding object.__dict__ is a VERY bad idea as it totally breaks any
# possibility of pickling this object. Pickling marshalls via object.__dict__
# via default __getstate__ and __setstate__ methods. This is now renamed to
# keep the functionality for the validators, but keep pickling operational.
@property
def __dict__(self):
def __newdict__(self):
return self._source or self.to_dict()

def to_dict(self):
Expand Down
2 changes: 1 addition & 1 deletion openapi_core/unmarshalling/schemas/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_validator(self, schema):
}
if self.context is not None:
kwargs[self.CONTEXT_VALIDATION[self.context]] = True
return OAS30Validator(schema.__dict__, **kwargs)
return OAS30Validator(schema.__newdict__, **kwargs)

def _get_format_checker(self):
fc = deepcopy(oas30_format_checker)
Expand Down