OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] properties which readOnly: true
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
When importing openapi schema definition information about readOnly: true properties are not propagated properly. I would expect to import schema model and reuse it same way.
openapi-generator version
7.11.0
7.11.0
OpenAPI declaration file content or url
https://gist.github.com/narciarz/4aa97ab4314e23ae616ebee235f9876b
Generation Details
Steps to reproduce
Scenario:
- Importing openapi definition via openapi-generator cli or maven plugin
- POJOs created ( lacking information about readOnly)
- Import POJOs inside java app, created some crud using those models
- Expose APIs within POJOs
- Generate for example swagger-ui using spring / springdoc library
- Looking on req field which supossed to be readOnly (my case "id") is not. Inside resp all were available so it's ok.
Related issues/PRs
Suggest a fix
using JacksonAnnotation it will be sufficient to add access = JsonProperty.Access.READ_ONLY on getter or above such field. Currently there is annotation such:
@JsonProperty(JSON_PROPERTY_FIELDNAME)
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
Start with the linked OpenAPI declaration and reproduce the issue through the Java generator CLI or Maven plugin. Inspect the generated POJO's Jackson annotations, especially the existing @JsonProperty output. Done means a readOnly property such as "id" remains marked read-only when the generated models are used to expose the API and generate Swagger UI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100