Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [spring] [server] 5.0.1 unused imports in generated interfaces #8776

Open
2 of 6 tasks
lfischer opened this issue Feb 20, 2021 · 4 comments
Open
2 of 6 tasks

[BUG] [spring] [server] 5.0.1 unused imports in generated interfaces #8776

lfischer opened this issue Feb 20, 2021 · 4 comments

Comments

@lfischer
Copy link

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

Generated API interfaces contain the following unused imports, which introduce unnecessary dependencies:

  • import org.springframework.data.domain.Pageable;
  • import springfox.documentation.annotations.ApiIgnore;
openapi-generator version

5.0.1

OpenAPI declaration file content or url

https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Generation Details
Steps to reproduce

file "springboot-options.json"

{
"basePackage":"io.swagger",
"configPackage":"io.swagger.config",
"parentGroupId":"org.springframework.boot",
"parentArtifactId":"spring-boot-starter-parent",
"parentVersion":"2.4.3",
"serverPort":9230,
"dateLibrary":"java8"
}

command line

java -jar ./openapi-generator-cli-5.0.1.jar generate -g spring -i petstore.yaml -o server\springboot\openapi -c springboot-options.json

Example: imports within generated file UserApi

package org.openapitools.api;

import java.util.List;
import org.openapitools.model.User;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

Related issues/PRs
Suggest a fix

Remove imports of springfox.documentation.annotations.ApiIgnore and data.domain.Pageable within the api interfaces, as they are not used and not needed.

@auto-labeler
Copy link

auto-labeler bot commented Feb 20, 2021

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@piotrpolak
Copy link

piotrpolak commented Feb 25, 2021

I am facing the same issue after upgrading from 4.2.3.

I explicitly disabled useSpringfox in my configuration but no luck:

{
  // ...
  "useSpringfox": false,
  "reactive": false
}

@morphlne
Copy link
Contributor

morphlne commented Mar 8, 2021

This issue described earlier in #8360

@flabbamann
Copy link

Seems to be fixed in 5.3.0

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

No branches or pull requests

4 participants