Skip to content
Advertisement

Swagger codegen generates duplicated variables

I’m trying to generate client from yaml that contains

JavaScript

That means, accept and contentType will be present in generated method signature.

On top of that, I’v configured plugin like this

JavaScript

Still, after mvn clean install

I’m getting

Error:(130,31) java: variable accept is already defined in method

And generated code contains

JavaScript

I’v tried different versions of plugin (from 2.3.0 up to newest one), after overcoming lots of other issues, I’m always ending up like this.

Advertisement

Answer

In OpenAPI 2.0, the Accept and Content-Type headers should be defined using consumes and produces rather than parameters. In OpenAPI 3.0, these headers are defined as request/response media types.

Change your operation definition as follows:

JavaScript

or if you use OpenAPI 3.0:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement