diff --git a/src/openapi_parser/builders/parameter.py b/src/openapi_parser/builders/parameter.py index f180410..c7920e2 100644 --- a/src/openapi_parser/builders/parameter.py +++ b/src/openapi_parser/builders/parameter.py @@ -42,6 +42,8 @@ def build(self, data: dict) -> Parameter: "required": PropertyMeta(name="required", cast=None), "schema": PropertyMeta(name="schema", cast=self.schema_factory.create), "description": PropertyMeta(name="description", cast=str), + "example": PropertyMeta(name="example", cast=None), + "examples": PropertyMeta(name="examples", cast=None), "deprecated": PropertyMeta(name="deprecated", cast=None), "explode": PropertyMeta(name="explode", cast=None), } diff --git a/src/openapi_parser/specification.py b/src/openapi_parser/specification.py index a53a6a3..01d066c 100644 --- a/src/openapi_parser/specification.py +++ b/src/openapi_parser/specification.py @@ -155,8 +155,8 @@ class Parameter: schema: Schema required: Optional[bool] = field(default=False) description: Optional[str] = None - # example: Optional[Any] # TODO - # examples: list[Any] = field(default_factory=list) # TODO + example: Optional[Any] = None + examples: list[Any] = field(default_factory=list) # allow_reserved: bool # TODO deprecated: Optional[bool] = field(default=False) style: Optional[str] = None diff --git a/tests/openapi_fixture.py b/tests/openapi_fixture.py index 4ebdc6d..11f52ea 100644 --- a/tests/openapi_fixture.py +++ b/tests/openapi_fixture.py @@ -281,6 +281,7 @@ def create_specification() -> Specification: name="uuid", location=ParameterLocation.PATH, description="User unique id", + example="12345678-1234-5678-1234-567812345678", required=True, explode=False, style=PathParameterStyle.SIMPLE, @@ -306,6 +307,7 @@ def create_specification() -> Specification: name="limit", location=ParameterLocation.QUERY, description="Result items limit", + example=10, required=True, explode=True, style=QueryParameterStyle.FORM, @@ -315,6 +317,7 @@ def create_specification() -> Specification: name="offset", location=ParameterLocation.QUERY, description="Result items start offset", + example=0, required=True, explode=True, style=QueryParameterStyle.FORM,