OpenAPITools / OpenAPITools/openapi-generator
JAX-RS spec model generation missing @JsonProperty-Annotation on setters
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
JAX-RS spec model generation: The following annotation is missing on setters in pojo.mustache:
@JsonProperty("{{baseName}}")
so the json body on POST-Requests are not transformed to camel case property names. The opposite direction (responses bodies) with dashed property names are converted correctly.
openapi-generator version
Version 5.1.0
Maven Command line used for generation
<execution>
<id>openapi-codegen-java-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/openapi.yaml</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>jaxrs-spec</generatorName>
<templateDirectory>custom-templates</templateDirectory>
<apiPackage>de.gebit.rp.template3.ohcaa.api</apiPackage>
<generateApis>false</generateApis>
<generateApiDocumentation>false</generateApiDocumentation>
<generateApiTests>false</generateApiTests>
<modelPackage>de.gebit.rp.template3.ohcaa.api.model</modelPackage>
<generateModels>true</generateModels>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<configOptions>
<sourceFolder>.</sourceFolder>
<openApiSpecFileLocation>openapi-generated.yaml</openApiSpecFileLocation>
<interfaceOnly>true</interfaceOnly>
<generatePom>false</generatePom>
<useBeanValidation>true</useBeanValidation>
<useSwaggerAnnotations>false</useSwaggerAnnotations>
<returnResponse>true</returnResponse>
<dateLibrary>java8</dateLibrary>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<useTags>true</useTags>
<generateBuilders>false</generateBuilders>
</configOptions>
</configuration>
</execution>
Steps to reproduce
Provide an openapi spec with schema elements with dashed property names for example:
components:
schemas:
Error:
type: object
properties:
error_name:
type: string
error_detail:
type: string
Suggest a fix/enhancement
Add @JsonProperty in
pojo.mustache line 50:
...
@JsonProperty("{{baseName}}")
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
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 pojo.mustache around line 50 and generate a jaxrs-spec model from an OpenAPI schema containing dashed property names such as error_name. Verify the generated setters include the requested @JsonProperty annotation and that the generated model handles the property names correctly for POST request bodies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100