Skip to content

remove unused import org.openapitools.jackson.nullable.JsonNullable from generated model #2901

@pellyadolfo

Description

@pellyadolfo

Bug Report Checklist

  • [ X] Have you provided a full/minimal spec to reproduce the issue?
  • [ X] Have you validated the input using an OpenAPI validator (example)?
  • [ X] What's the version of OpenAPI Generator used?
  • [ X] Have you search for related issues/PRs?
  • [X ] What's the actual output vs expected output?
  • [X ] [Optional] Bounty to sponsor the fix (example)
Description

When I generate the model there is an unused import org.openapitools.jackson.nullable.JsonNullable; in every single DTO. It forces me to add a dependency.

	<dependency>
	    <groupId>org.openapitools</groupId>
	    <artifactId>jackson-databind-nullable</artifactId>
	    <version>0.1.0</version>
	</dependency>

Unfortunately this dependency must be approved in the company so the model is unusable.

Is there any way to get rid of this unused import? Configuration is below:

		<plugin>
		    <groupId>org.openapitools</groupId>
		    <artifactId>openapi-generator-maven-plugin</artifactId>
		    <version>4.0.0</version>
		    <executions>
		        <execution>
		            <goals>
    			        <goal>generate</goal>
    			    </goals>
        			<configuration>
				<inputSpec>${maven.multiModuleProjectDirectory}/api/target/generated/swagger-api-spec/swagger.json</inputSpec>	
					<language>spring</language>
					<library>spring-boot</library>
					<model-name-prefix>Cqrs</model-name-prefix>
					<modelPackage>com.anthem.specialty.provider.springapi.model</modelPackage>
					<apiPackage>com.anthem.specialty.provider.springapi.api</apiPackage>
					<invokerPackage>com.anthem.specialty.provider.springapi.invoker</invokerPackage>
        			    <skipValidateSpec>true</skipValidateSpec>
					<generateSupportingFiles>true</generateSupportingFiles>
					<supportingFilesToGenerate>
						ApiApi.java,ApiApiControler.java,ApiUtil.java
					</supportingFilesToGenerate>
        			    <configOptions>
					<sourceFolder>src/gen/java/main</sourceFolder>
					<java8>false</java8>
					<dateLibrary>java8</dateLibrary>
					<interfaceOnly>false</interfaceOnly>
					<groupId>com.company</groupId>
					<artifactId>${project.artifactId}</artifactId>
					<artifactVersion>${project.version}</artifactVersion>
        		    		</configOptions>
        			</configuration>
	        	</execution>
		    </executions>
		</plugin>	
openapi-generator version
		    <groupId>org.openapitools</groupId>
		    <artifactId>openapi-generator-maven-plugin</artifactId>
		    <version>4.0.0</version>
OpenAPI declaration file content or url

probably convenient enhancement

Command line used for generation

maven plugin

Steps to reproduce

run the maven clean install

Related issues/PRs

a few similar issues

Suggest a fix

provide a mechanism to remove unused imports

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions