swagger-codegen-maven-plugin ignores multiple occurences of a path (with different content types)
Imagine you would like to return data either in JSON or CSV format based on the provided "accepts" header parameter. In Spring you can implement 2 different methods with almost the same @GetMapping annotation... and it would work.
@GetMapping(value = "/data", produces = {"application/JSON"}) public ResponseEntity<SomeDtoWithJsonAnnotations> getDataAsJson() {...} @GetMapping(value = "/data", produces = {"text/csv"}) public ResponseEntity<byte[]> getDataAsCsv() {...}
If you try to achieve smtg similar in YAML and then to generate Spring source code (swagger-codegen-maven-plugin, language: spring, version: 2.4.6):
/data:
get: operationId: getDataAsJson consumes: - application/json; charset=utf-8 produces: - application/json; charset=utf-8 responses: 200: schema: $ref: "#/definitions/DataResponse" /data: get: operationId: getDataAsCsv consumes: - application/json; charset=utf-8 produces: - text/csv responses: 200: schema: type: string format: byte
The first definition (operationId = 'getDataAsJson") is ignored and only the second definition (operationId = "getDataAsCsv") is generated.
On console there is no error, maven build is successful.
Is it a defect?
I would at least expect a build failure saying the path is being used twice. However, a total ignorance of the first definition is a surprise to me.
What do you think, guys?