`anyOf` in responses generates invalid body parser
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start with the OpenAPI Spec File linked in the issue and reproduce the generated _parse_response_200 example for a response schema using anyOf. Compare the generated parser branches and verify that the output is valid and can parse both the fixed-value and Response200 alternatives.
Written by the indexing model from the issue text.
Description
Describe the bug
When a response media type has an anyOf schema, the generated code does not parse it properly/is not valid. (see add'l context)
OpenAPI Spec File
https://gist.github.com/nkrishnaswami/8c4a2068d8ac59cab153136a6069b44d
Desktop (please complete the following information):
- OS: macOS 15.6
- Python Version: 3.12.8
- openapi-python-client version: git revision
13bf2e8
Additional context
def _parse_response_200(data: object) -> Union["Response200", Literal["Why have a fixed response? I dunno"]]:
response_200_type_0 = cast(Literal["Why have a fixed response? I dunno"], data)
if response_200_type_0 != "Why have a fixed response? I dunno":
raise ValueError(
f"response_200_type_0 must match const 'Why have a fixed response? I dunno', got '{response_200_type_0}'"
)
return response_200_type_0
if not isinstance(data, dict):
raise TypeError()
response_200_type_1 = Response200.from_dict(data)
return response_200_type_1
- Dominant language
- Python
- Stars
- 2k
- Forks
- 293
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openapi-generators/openapi-python-client
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
openapi-generators/openapi-python-client#1451 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
openapi-generators/openapi-python-client#1435 · 1 comment ·
All issues in openapi-generators/openapi-python-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/skills#1811 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
speaches-ai/speaches#678 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
datalayer/mcp-compose#42 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
UKGovernmentBEIS/inspect_evals#2523 ·