openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][Spring] ReadOnly is ignored if the property is in a ref resource

Open ernesto-arm opened this issue 1 year ago • 0 comments

Description

ReadOnly in an $ref resource is annotated with @NotNull

openapi-generator version

7.4.0 and 6.6.0

OpenAPI declaration file content or url

https://gist.github.com/ernesto-arm/300d15c63661e91854b5213f53d0c475

Command line used for generation

mvn compile

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>7.4.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>
                    ${project.basedir}/src/main/resources/contract.yaml
                </inputSpec>
                <generatorName>spring</generatorName>
                <documentationProvider>springfox</documentationProvider>
                <serializableModel>true</serializableModel>
                <apiPackage>com.acme.api</apiPackage>
                <modelPackage>com.acme.model</modelPackage>
                <serverVariableOverrides>basePath=/</serverVariableOverrides>
                <configOptions>
                    <sourceFolder>src/main/java</sourceFolder>
                    <delegatePattern>true</delegatePattern>
                    <openApiNullable>false</openApiNullable>y
                    <performBeanValidation>true</performBeanValidation>
                    <generateApiTests>false</generateApiTests>
                    <generateModelTests>false</generateModelTests>
                    <useTags>true</useTags>
                    <annotationLibrary>swagger2</annotationLibrary>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>
Steps to reproduce
  1. after the generator is run with mvn compile
  2. in Purchase class the getName which is readonly and required does not generate the @NotNull
  3. in Purchase class the getLinks which is readonly and required but as an external reference does generate the @NotNull annotation
Related issues/PRs
Suggest a fix/enhancement

ernesto-arm avatar Apr 26 '24 10:04 ernesto-arm