OpenAPITools / OpenAPITools/openapi-generator

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

Open
#18,508 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked OpenAPI declaration and run the supplied Maven generation configuration. Compare the generated Purchase getters for the inline name property and the externally referenced links property; done means the ReadOnly and required combination produces consistent @NotNull annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.