OpenAPITools / OpenAPITools/openapi-generator
[REQ] Kotlin property-name different from JSON-Property-name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Yes. I have an open-api specification for a very old and primitive REST-API. Therefor very cryptic json-field-names such as APEPNN oder APEJSN are used. I'd like to match these field names through a @JsonProperty-annotation but use a more descriptive name for my kotlin-bean (e.g. APEPNN results into 'name' or APEJSN results into 'description')
Describe the solution you'd like
I think a vendor-extension would already help. If I could provide an additional field such as 'x-propertyname', which is then used for naming the property in the kotlin-class, it is all I need.
Describe alternatives you've considered
Rewriting/Customizing a template. But unfortunately I'm currently stuck to the 5-version because of the incompatibility-issue with snakeyaml with Spring 2.7.
I think this could be useful for other people as well, so I would prefer a more general approach.
Additional context
This is the result I would like to have
@field:JsonProperty("APEPNN")
val myName: kotlin.String? = null,
is the result from the following openapi-spec:
APEPNN:
type: string
x-propertyname: myName
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 Kotlin generator template and the property-naming path that produces the shown bean output; the issue does not name a specific file or test. Check how the x-propertyname vendor extension could affect generated Kotlin properties while preserving @JsonProperty("APEPNN"). Done means the provided specification generates myName as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, openapi
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100