Skip to content

Commit cfe7fce

Browse files
authored
Merge pull request #53 from codectl/fix/#52
append response parameter if no schema is to be resolved
2 parents 957f36a + 9a4d617 commit cfe7fce

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/apispec_plugins/ext/pydantic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def resolve_parameters(self, parameters: list[dict]) -> None:
102102
for media_type in parameter["content"].values():
103103
self.resolve_schema(media_type)
104104
params.append(parameter)
105+
else:
106+
params.append(parameter)
105107
parameters[:] = params[:]
106108

107109
def resolve_response(self, response: dict) -> None:

tests/ext/test_pydantic.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,23 @@ class TestPydanticPlugin:
3838
def test_resolve_parameter(self, spec, schema):
3939
spec.path(
4040
path="/pet/{petId}",
41-
operations={"get": {"parameters": [{"in": "path", "schema": schema}]}},
41+
operations={
42+
"get": {
43+
"parameters": [
44+
{"in": "path", "name": "petId", "schema": {"type": "string"}},
45+
{"in": "path", "schema": schema},
46+
]
47+
}
48+
},
4249
)
4350

4451
path = get_paths(spec)["/pet/{petId}"]
4552
props = Pet.schema()["properties"]
53+
required = {"required": True}
4654
assert path["get"]["parameters"] == [
47-
{"in": "path", "name": "id", "schema": props["id"], "required": True},
48-
{"in": "path", "name": "name", "schema": props["name"], "required": True},
55+
{"in": "path", "name": "petId", "schema": {"type": "string"}, **required},
56+
{"in": "path", "name": "id", "schema": props["id"], **required},
57+
{"in": "path", "name": "name", "schema": props["name"], **required},
4958
]
5059

5160
@pytest.mark.parametrize("spec", ("3.0.3",), indirect=True)

0 commit comments

Comments
 (0)