Skip to content

Commit 9f5b95a

Browse files
committed
Bug fix for allOf with no properties
1 parent 2670d11 commit 9f5b95a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: openapi_python_client/parser/openapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def from_data(*, data: oai.Schema, name: str) -> Union["Model", ParseError]:
279279
for sub_prop in data.allOf:
280280
if isinstance(sub_prop, oai.Reference):
281281
references += [sub_prop]
282-
else:
282+
elif sub_prop.properties:
283283
all_props.update(sub_prop.properties)
284284
required_set.update(sub_prop.required or [])
285285

Diff for: tests/test_openapi_parser/test_openapi.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,18 @@ def test_resolve_references(self, mocker):
173173
"Float": oai.Schema.construct(type="number", format="float")
174174
},
175175
),
176+
# Intentionally no properties defined
177+
"RefC": oai.Schema.construct(
178+
title=mocker.MagicMock(),
179+
description=mocker.MagicMock(),
180+
),
176181
}
177182

178183
model_schema = oai.Schema.construct(
179184
allOf=[
180185
oai.Reference.construct(ref="#/components/schemas/RefA"),
181186
oai.Reference.construct(ref="#/components/schemas/RefB"),
187+
oai.Reference.construct(ref="#/components/schemas/RefC"),
182188
oai.Schema.construct(
183189
title=mocker.MagicMock(),
184190
description=mocker.MagicMock(),
@@ -195,7 +201,6 @@ def test_resolve_references(self, mocker):
195201

196202
model = Model.from_data(data=model_schema, name="Model")
197203
model.resolve_references(schemas)
198-
print(f"{model=}")
199204
assert sorted(p.name for p in model.required_properties) == ["DateTime", "Float", "String"]
200205
assert all(p.required for p in model.required_properties)
201206
assert sorted(p.name for p in model.optional_properties) == ["Enum", "Int"]

0 commit comments

Comments
 (0)