Openapi-generator: JAVA-SPRING model generation: disable swagger annotations import

Created on 22 Sep 2018  路  8Comments  路  Source: OpenAPITools/openapi-generator

Description

Hi i m using java spring generator and i did not find an option to disable the import of
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
inside my model code generated.
Checking the source code openapi-generator-3.2.3modulesopenapi-generatorsrcmainresourcesJavaSpringmodel.mustache
i found that the ApiModel and ApiModelProperty are imported with mustache instructions

{{#imports}}import {{import}};
{{/imports}}

So i cant customize the mustache to disable it because {{import}} contains other useful import.

openapi-generator version

3.2.3

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Most helpful comment

Any news on this? I'd need this feature too.

All 8 comments

Suggest a fix/enhancement : add a proprs to control swagger annotations

Hi,

I had the same issue with generating model with @ApiModel and @ApiModelProperty

It is not needed in a model. In addition, it is generating the model with the open API v3 spec. That makes it worse.

I am trying to customize the template by removing all references to swagger libraries. But it does not seem to work.
(https://openapi-generator.tech/docs/templating)

Wayne

Hi,

Do you have any news about this fix/enhancement?

Mathieu.

Hi all,

i have the same requirements. i will only generate interface an model classes with no dependencies pointing to io.swagger.

I try to fix this issue and will provide a fix/enhancement.

Kind regards,
Andreas

This is not only a spring problem but all java in general. Each template wants to add it's own dependencies, you can't generate a clean native java model with any templates right now, at least not to my knowledge. It should be possible to disable any external dependencies with a config option.

Any news on this? I'd need this feature too.

Ran into the same issue - as I'm using openapi-generator to create a client to consume an existing external API, I don't need (or want) the swagger annotations as I won't be reproducing documentation already available from an external party.

we are generating from a proper OASv3, we dont need or want any swagger-v2 dependencies in our generated model - please make this configurable!

Was this page helpful?
0 / 5 - 0 ratings