Reputation: 155
I use maven Swagger Codegen V3 plugin to generate API from a yaml file. I want to generate different versions of a rest request which has the same path but different body types.
I use this YAML code to generate it.
content:
application/json;version=1.0.0:
schema:
$ref: '#/components/schemas/Object1'
application/json;version=2.0.0:
schema:
$ref: '#/components/schemas/Object2'
And I get the following result:
@Consumes({ "application/json;version=1.0.0", "application/json;version=2.0.0" })
...
public void method(Object1 body);
@Consumes({ "application/json;version=1.0.0", "application/json;version=2.0.0" })
...
public void method(Object2 body);
But the result I need is like below.
@Consumes({ "application/json;version=1.0.0" })
...
public void method(Object1 body);
@Consumes({ "application/json;version=2.0.0" })
...
public void method(Object2 body);
I use the consumes parameter for the versioning. So is there a way to get the result I want?
Upvotes: 2
Views: 2411
Reputation: 156
It's a limitation Swagger Codegen v3 does not support multiple payload at the moment. The Petstore OpenAPI document has endpoints that can send either JSON or XML payload but the output (auto-generated code) only supports JSON at the moment.
Upvotes: 2