OpenAPITools / OpenAPITools/openapi-generator
[BUG] Unused JsonNullable imports
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- [] Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
An import import org.openapitools.jackson.nullable.JsonNullable; is being added to DTOs despite they're never used.
It's solvable by adding <openApiNullable>false</openApiNullable> config property but I believe the import shouldn't be there if it's unused.
openapi-generator version
7.0.1. Might be a regression of #2901
OpenAPI declaration file content or url
https://gist.github.com/Haarolean/8a9b07f74544c7e45d553ff33798ed8c (swagger petstore)
Generation Details
maven,
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.0.1</version>
<executions>
<execution>
<id>interfaces</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<output>${project.build.directory}/generated-sources/api</output>
<generatorName>spring</generatorName>
<modelNameSuffix>DTO</modelNameSuffix>
<configOptions>
<modelPackage>lol.memelord.kapybro.api.dto</modelPackage>
<apiPackage>lol.memelord.kapybro.api.api</apiPackage>
<sourceFolder>test</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<useBeanValidation>true</useBeanValidation>
<useTags>true</useTags>
<useSpringBoot3>true</useSpringBoot3>
<dateLibrary>java8</dateLibrary>
<!-- <useOpenApiNullable>false</useOpenApiNullable>-->
<!-- <openApiNullable>false</openApiNullable>-->
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Steps to reproduce
- build the spec
Related issues/PRs
#2901
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the linked Petstore specification and the Maven configuration using generatorName spring and version 7.0.1. Inspect the Spring generator output and existing regression tests for DTO imports; done means generated DTOs do not contain an unused JsonNullable import when nullable support is not needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100