openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

`anyOf` in responses generates invalid body parser

Open nkrishnaswami opened this issue 5 months ago • 0 comments

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

nkrishnaswami avatar Jun 03 '25 15:06 nkrishnaswami