Skip to content

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

Description

@alexalmeida52

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions