Skip to content

Add extensions support for the Parameter model #308

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 1 commit into from
Mar 31, 2021
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
9 changes: 9 additions & 0 deletions openapi_core/schema/parameters/factories.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""OpenAPI core parameters factories module"""
from openapi_core.compat import lru_cache
from openapi_core.schema.content.factories import ContentFactory
from openapi_core.schema.extensions.generators import ExtensionsGenerator
from openapi_core.schema.parameters.models import Parameter


Expand Down Expand Up @@ -32,14 +33,22 @@ def create(self, parameter_spec, parameter_name=None):
if content_spec:
content = self.content_factory.create(content_spec)

extensions = self.extensions_generator.generate(parameter_deref)

return Parameter(
parameter_name, parameter_in,
schema=schema, required=required,
allow_empty_value=allow_empty_value,
style=style, explode=explode, content=content,
extensions=extensions,
)

@property
@lru_cache()
def content_factory(self):
return ContentFactory(self.dereferencer, self.schemas_registry)

@property
@lru_cache()
def extensions_generator(self):
return ExtensionsGenerator(self.dereferencer)
4 changes: 3 additions & 1 deletion openapi_core/schema/parameters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class Parameter(object):
def __init__(
self, name, location, schema=None, required=False,
deprecated=False, allow_empty_value=False,
items=None, style=None, explode=None, content=None):
items=None, style=None, explode=None, content=None,
extensions=None):
self.name = name
self.location = ParameterLocation(location)
self.schema = schema
Expand All @@ -31,6 +32,7 @@ def __init__(
self.style = ParameterStyle(style or self.default_style)
self.explode = self.default_explode if explode is None else explode
self.content = content
self.extensions = extensions and dict(extensions) or {}

@property
def aslist(self):
Expand Down