Apicurio / apicurio-codegen

Repository to hold some code generation utilities.
Apache License 2.0
4 stars 13 forks source link

How to generate classes with @NotNull and @Valid annotations from Jakarta #270

Open alexalmeida52 opened 4 months ago

alexalmeida52 commented 4 months ago

I expected that when using the plugin, classes with Jakarta annotations would be generated. For example, a parameter that cannot be null would have the @NotNull annotation in the generated class and this would be validated.

However, I'm encountering the class being generated with comments about the attribute that serve no purpose.

For example, I have a "name" attribute that is required and in the generated class it is presented like this:

/**
  *
  * (Required)
  *
  */
@JsonProperty("name")
private String name;

Is it possible to generate with these Jakarta Validation annotations? If so, how to configure the maven plugin to achieve this result.

Below is my current configuration:

<plugin>
    <groupId>io.apicurio</groupId>
    <artifactId>apicurio-codegen-maven-plugin</artifactId>
    <version>${apicurio-codegen-maven.version}</version>
    <executions>
        <execution>
            <id>generate-tpfee-resources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <projectSettings>
                    <javaPackage>org.acme.application.rest.resources
                    </javaPackage>
                </projectSettings>
                <inputSpec>src/main/resources/api.json</inputSpec>
                <outputDir>./src/main/java/</outputDir>
            </configuration>
        </execution>
    </executions>
</plugin>