-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Description
Hi Team, Thanks for the great contribution of openapi-generator, This project helped me to generate a spring boot application automatically from openapi-spec with in few seconds (instead of manual work which takes minimum 1 or 2 days.)
- When I use the @lombok.Data in additionalModelTypeAnnotations with jackson serializationLibrary, the @JsonProperty annotation is missing in the generated java pojo model (because its included in the setter method of pojo only)
- In my use case I'm using Snake case for schema definition in my openapi spec
Eg: field name
in openapi spec: pet_purchased_date
in java pojo class: petPurchasedDate - It is causing issue when the input is converted to model in java
config:
openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/openapi.yaml".toString()
outputDir = "$buildDir/openapi".toString()
apiPackage = "org.petstore.rest"
modelPackage = "org.petstore.interfaces"
apiFilesConstrainedTo = [""]
modelFilesConstrainedTo = [""]
configOptions = [useSpringBoot3: "true", serializationLibrary: "jackson", hideGenerationTimestamp: "true", additionalModelTypeAnnotations: "@lombok.Data; @lombok.AllArgsConstructor; @lombok.NoArgsConstructor;"]
skipValidateSpec = true
globalProperties = [skipFormModel: "false"]
importMappings = [Problem:"org.zalando.problem.Problem", Data:"lombok.Data", NoArgsConstructor:"lombok.NoArgsConstructor", AllArgsConstructor:"lombok.AllArgsConstructor"]
}
Solution
Include the below line as mentioned as per below image in the pojo.mustache
{{#lombok.Data}}{{#jackson}}@JsonProperty("{{baseName}}"){{/jackson}}{{/lombok.Data}}
Thanks
Vishnu
