Skip to content

Incorrect code mapping when "Default" directive is used. #12481

Open
@tclasen

Description

@tclasen

Hello! I'm trying out the new 6.0 release and noticed it generated some invalid Python-FastAPI code. Here is the offending line of code:

{{code}}: {{=<% %>=}}{<%#dataType%>"model": <%dataType%>, "description": "<%message%>"<%/dataType%><%^dataType%>"description": "<%message%>"<%/dataType%>}<%={{ }}=%>,

And here is the OpenAPI.yaml that was used as input:

https://github.com/OAI/OpenAPI-Specification/blob/aa91a19c43f8a12c02efa42d64794e396473f3b1/examples/v3.0/petstore-expanded.yaml#L51

And lastly here is the invalid python code that was generated:

    responses={
        200: {"model": Pet, "description": "pet response"},
        200: {"model": Error, "description": "unexpected error"},
    },

In the openapi.yaml file there was a response model for status code 200 and a response model for "Default" (everything else). The code generator interpreted this "Default" as a 200 which resulted in a python dictionary with 2x keys for 200, which is invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions