[JAVA] json is adding property twice for classes starting with two capital letters
Description
We are using the swagger-codegen-cli to generate our classes, however, we noticed a strange case where a property that is referenced to (as object) in another .yaml, gets added twice in our json at serialization.. This is possibly caused by the file having a setter/getter with 2 capitals, eg: getDOfferStatus().
Example response:
"result": {
"dOfferStatus": {
"href": "",
"value": "BOOKABLE"
}
"dofferStatus":{
"href":"",
"value": "BOOKABLE"
}
}
Swagger-codegen version
swagger codegen-cli v3
Swagger declaration file content or url
openapi: 3.0.2
info:
version: 0.14.00
title: trip offers
description: trip offers
paths: {}
components:
schemas:
TripOfferSummary:
description: A set of offers for a given trip from origin to destination
type: object
properties:
dOfferStatus:
$ref: './otheryaml.openapi.yaml#/components/schemas/DOfferStatus'
Which is defined in the other yaml and gets generated inline as: notice we defined it with two capitals as it's a class.
DOfferStatus:
type: object
properties:
href:
type: string
format: uri
value:
type: string
format: urn
Command line used for generation
classpath = project.configurations["swaggerCodegen"] mainClass = 'io.swagger.codegen.v3.cli.SwaggerCodegen' args = [ 'generate', '--lang', spring, '--input-spec', inputFile, '--config', configFile, '--output', 'build' ]
config file: { "artifactId":"trip-offers-openapi", "language":"spring", "modelPackage":"com.system.trip_offers", "apiPackage":"com.system.api", "library":"spring-boot", "generateSupportingFiles":"false", "interfaceOnly":"true", "defaultInterfaces":"false", "singleContentTypes":"true", "dateLibrary":"java8-localdatetime", "importMappings": { "DOfferStatus":"com.otheryamlpackage.DOfferStatus", } }
Steps to reproduce
Generate the classes, and serialize/deserialize them.
Suggest a fix/enhancement
I tried using a class by copy pasting the generated code, and added @JsonProperty("dOfferStatus") to the getters and setters of the Java Class. This immediately resolved the issue.