OpenAPITools / OpenAPITools/openapi-generator
[REQ] Is it possible to customise field name generation?
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.
Hi Community,
I am using openapi-generator to generate Java/Kotling classes.
Recently, I confronted the following issue. For this part of the open-api spce
post:
description: Lets a user post a new artist
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MyObject'
components:
schemas:
MyObject:
type: object
properties:
SOME_NAME:
type: string
the generator generates this Kotlin data class
data class MyObject(
@JsoProperty("SOME_NAME")
val SOME_NAME: String
)
However, when Jackson tries to de serialize from this request json
{
"SOME_NAME": "name"
}
I get the error that the field with name sOME_NAME is not present in the object. I assume that Jackson follows the standard Java bean naming convenction.
So, I am wondering, is it possible to specify the name generation strategy so that SOME_NAME will be translated to someName?
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 by reproducing the example with the Kotlin generator and trace how the OpenAPI property SOME_NAME becomes a generated field. Check whether field-name generation is configurable and how Jackson annotations are emitted. Done means a configurable strategy can produce someName while deserializing the original SOME_NAME JSON property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100