OpenAPITools / OpenAPITools/openapi-generator
[BUG] [python-flask] Hosted UI doesn't match the openapi.json, missing readOnly information.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
- Modify the above petstore.yaml file
- 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 - Build & Run:
docker build -t openapi_server .,docker run -p 8080:8080 openapi_server - Visit
http://localhost:8080/api/v3/ui/#/pet/add_pet. Switch toapplication/x-www-form-urlencoded. The id field is no longer readOnly- it appears in the Request Body Parameters. - Download the
/api/v3/openapi.jsonfile from the UI, it still has the readOnly field, and it displays OK if pasted into https://editor.swagger.io/
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.
Research direction
Generate the modified petstore.yaml with the python-flask generator and inspect the hosted Swagger UI at /api/v3/ui/#/pet/add_pet. Compare the application/x-www-form-urlencoded request fields with /api/v3/openapi.json and the same specification in editor.swagger.io; done means the readOnly id field is treated consistently in the generated UI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, openapi, python
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100