Skip to content

[BUG][PYTHON] inline response types generate invalid code referring to UNKNOWNBASETYPE #8605

@RonnyPfannschmidt

Description

@RonnyPfannschmidt

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

using inline responses can generate unknown base types resulting in bad docs on 4.3.0 and bad code on 5.0.x

openapi-generator version

5.0.1 snapshot, 5.0, master

OpenAPI declaration file content or url

https://gist.github.com/RonnyPfannschmidt/71a7d9bc344be968f0fed5559b5ee502#file-apispec-json

Generation Details
docker run --rm --volume "${PWD}":/local:z \
    openapitools/openapi-generator-cli generate \
    -i /local/apispec.json \
    -g python \
    -o /local/package

and for comparison with 4.3.1

docker run --rm --volume "${PWD}":/local:z \
    openapitools/openapi-generator-cli:v4.3.1 generate \
    -i /local/apispec.json \
    -g python \
    -o /local/package
Steps to reproduce
$ ag UNKNOWNBASETYPE package/
package/openapi_client/api/example_api.py
25:from openapi_client.model.unknownbasetype import UNKNOWNBASETYPE

package/docs/ExampleApi.md
24:from openapi_client.model.unknownbasetype import UNKNOWNBASETYPE

package/README.md
54:from openapi_client.model.unknownbasetype import UNKNOWNBASETYPE

and on v4.3.1

$ ag UNKN package/
package/openapi_client/api/example_api.py
50:        :param UNKNOWN_BASE_TYPE unknown_base_type:
76:        :param UNKNOWN_BASE_TYPE unknown_base_type:

package/README.md
68:unknown_base_type = openapi_client.UNKNOWN_BASE_TYPE() # UNKNOWN_BASE_TYPE |  (optional)

package/docs/ExampleApi.md
37:unknown_base_type = openapi_client.UNKNOWN_BASE_TYPE() # UNKNOWN_BASE_TYPE |  (optional)
52: **unknown_base_type** | [**UNKNOWN_BASE_TYPE**](UNKNOWN_BASE_TYPE.md)|  | [optional] 
Related issues/PRs
Suggest a fix

My understanding is that a inline type should be generated for inline responses,
i would expect either a creation/usage of a inline type or an error suggesting extraction of the schema

depending on how hard this is, schema validators should also report this as warning/issue

a in-spec solution is to extract inline schemas to explicit schemas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions