swagger-api / swagger-api/swagger-codegen
readOnly field shouldn't have a set property with Java CodeGen
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
If you have a field marked as readOnly in your schema, the Java code generator still renders a set Method. For example:
"uri": {
"description": "URI of the object",
"type": "string",
"readOnly": true
}
And the generator gives me:
@ApiModelProperty(value = "URI of the object")
@JsonProperty("uri")
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
A read only field should not be settable.
This is using the Swagger Editor Version 2.9.8 online at http://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
Start at the Java code generator entry point used by Swagger Editor and trace how the readOnly schema property is rendered. Verify that generated models omit a setter for readOnly fields while retaining the getter, then run the relevant generator tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100