swagger-api / swagger-api/swagger-codegen
customize property name
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Discussed in https://github.com/swagger-api/swagger-codegen/discussions/11103
Originally posted by cielowu July 22, 2021
In the generated Java model code, we're assuming we want to generate a model that using the same name as defined in the schema. Thus, as long as the schema name does not violate certain rules, the generated model will always be
@JsonProperty("name")
private final String name;
but sometimes we want to customize the property name or the variable name by self-defined it, such as
@JsonProperty("n")
private final String name;
Is it possible to do so with swagger?
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
The issue names no implementation file, template, or test. Start by tracing Java model generation and how schema property names become @JsonProperty values; done means documenting or implementing a supported way to choose a different serialized property name from the generated Java field name, with coverage for the example case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100