How to make OpenAPI java generator add @JsonCreator annotation?

77 Views Asked by At

I have a number of OpenApi specs from which I gnerate java code using the Gradle Openapi generator plugin. Recently I had to change the config in order to generate classes annotated with @Serdeable. But at the same time, the generated fromValue(...) methods are no longer annoated with @JsonCreator which is a problem as some enum values in the OpenApi specs contain hyphens, e.g. X_HIGH("X-HIGH").

Is there some obscure config option that needs to be set? My current config:

openApiGenerate {
    generatorName = "java-micronaut-client"
    inputSpec = definitionDir + "/contact-points-api.yaml"
    apiPackage = "contact-points.api"
    modelPackage = "contact-points.model"
    additionalProperties = [
        removeEnumValuePrefix: "false"
    ]
    configOptions = [
        generateSwaggerAnnotations: "false",
        openApiNullable: "false",
        requiredPropertiesInConstructor: "false",
        wrapInHttpResponse: "true",
        useJakartaEe: "true",
        serializationLibrary: "micronaut_serde_jackson",
        micronautVersion: micronautVersion,
        datetimeFormat: "yyyy-MM-dd'T'HH:mm:ssXXXXX"
    ]
}
0

There are 0 best solutions below