Skip to content

Commit

Permalink
v3x/parameter - complex content encoding is not implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Sep 22, 2023
1 parent 55b200d commit 7778441
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
17 changes: 12 additions & 5 deletions aiopenapi3/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,19 @@ def is_schema(v: Tuple[str, "SchemaType"]) -> bool:
op: Operation = getattr(obj, m)

for parameter in op.parameters + obj.parameters:
if isinstance(parameter.schema_, ReferenceBase):
schema = parameter.schema_._target
if parameter.schema_:
if isinstance(parameter.schema_, ReferenceBase):
schema = parameter.schema_._target
else:
schema = parameter.schema_
name = schema._get_identity("I2", f"{path}.{m}.{parameter.name}")
byname[name] = schema
else:
schema = parameter.schema_
name = schema._get_identity("I2", f"{path}.{m}.{parameter.name}")
byname[name] = schema
for key, mediatype in parameter.content.items():
schema = mediatype.schema_
name = schema._get_identity("I2", f"{path}.{m}.{parameter.name}.{key}")
byname[name] = schema
raise NotImplementedError("https://github.com/commonism/aiopenapi3/issues/163")

if op.requestBody:
for content_type, request in op.requestBody.content.items():
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ def with_paths_parameter_format(openapi_version):
yield _get_parsed_yaml("paths-parameter-format.yaml", openapi_version)


@pytest.fixture
def with_paths_parameter_format_complex(openapi_version):
"""
parameters formatting
"""
yield _get_parsed_yaml("paths-parameter-format-complex.yaml", openapi_version)


@pytest.fixture
def with_paths_parameter_format_v20():
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/path_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ def test_paths_parameter_format(httpx_mock, with_paths_parameter_format):
return


@pytest.mark.xfail(raises=NotImplementedError, reason="https://github.com/commonism/aiopenapi3/issues/163")
def test_paths_parameter_format_complex(httpx_mock, with_paths_parameter_format_complex):
OpenAPI(URLBASE, with_paths_parameter_format_complex, session_factory=httpx.Client)


def test_paths_response_header(httpx_mock, with_paths_response_header):
httpx_mock.add_response(
headers={"Content-Type": "application/json", "X-required": "1", "X-optional": "1,2,3"}, json="get"
Expand Down

0 comments on commit 7778441

Please sign in to comment.