OpenAPI generator add annotation on field level
Asked Answered
N

1

10

I am using openapi generator (5.4.0) with gradle(7.3.3) and SpringBoot (2.6.6).

my OpenApi configuration:

  ext.openApiConfigOptions = [
            library                       : "spring-boot",
            dateLibrary                   : "java8",
            delegatePattern               : "true",
            useTags                       : "true",
            openApiNullable               : "false",
            additionalModelTypeAnnotations: "@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor",
            booleanGetterPrefix           : "is"
    ]

My goal is to add the @lombok.Builder.Default annotation over the field.

From documentation: enter image description here

According to this: link to example I tried using x-field-extra-annotation: in my spec, but it doesn't work in my case.

In my case it works like this;

  • x-extra-annotation:"@lombok.Builder.Default" adds an annotation over the getter.
  • The; x-setter-extra-annotation:"@lombok.Builder.Default" results in adding an annotation to the setter.
  • But; x-field-extra-annotation has no effect.

Similar unanswered question: link

Negress answered 24/5, 2022 at 11:46 Comment(0)
N
6

Upgrading the openapi generator to version 6.0.0 solves the problem.

Negress answered 26/5, 2022 at 12:2 Comment(2)
Looks like openapi generator v6.0 is still in beta and not available to us via Artifactory unfortunately. If it is please let me know, I tried adding it and maven couldn't pull the v6.0 dependencyInvestigate
@Investigate It has been released 20 hours ago, see github.com/OpenAPITools/openapi-generator/releases/tag/v6.0.0Kickback

© 2022 - 2024 — McMap. All rights reserved.