OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.62k stars 6.53k forks source link

[BUG] [python-flask] Hosted UI doesn't match the openapi.json, missing readOnly information. #7810

Open jethrogillgren opened 3 years ago

jethrogillgren commented 3 years ago
Description

It seems like readOnly fields get dropped from the Swagger UI after generating the server stub.

The spec downlaoded from the server at /api/v3/openapi.json still holds the readOnly field, and it shows correctly in the public https://editor.swagger.io/ , but the Swagger UI hosted by the generated server doesn't respect it.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

Start with https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml and set the following property:

    components:
      schemas:
        Pet:
          properties:
            id:
              readOnly: true
Steps to reproduce & generate
  1. Modify the above petstore.yaml file
  2. Generate a python-flask server: docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v4.3.1 generate --input-spec /local/petstore.yaml --generator-name python-flask --output /local
  3. Build & Run: docker build -t openapi_server ., docker run -p 8080:8080 openapi_server
  4. Visit http://localhost:8080/api/v3/ui/#/pet/add_pet. Switch to application/x-www-form-urlencoded. The id field is no longer readOnly- it appears in the Request Body Parameters.
  5. Download the /api/v3/openapi.json file from the UI, it still has the readOnly field, and it displays OK if pasted into https://editor.swagger.io/
auto-labeler[bot] commented 3 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.