openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][JAVA] Multiple response media types causing wrong @RequestMapping(produces=example)

Open jgarciasm opened this issue 1 year ago • 1 comments

Bug Report Checklist

  • [X] 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?
  • [X] Have you searched for related issues/PRs?
  • [X] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I have an openapi specification that contains an endpoint with 2 possible responses (201 and 4xx). Each one has a media type different. When it is generated the api code it is generated something like this:

https://gist.github.com/jgarciasm/5853cf0dac2a2eb597981db065574f60

That code generates the following error when trying to run/debug:

´´´ org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invalid mapping on handler class [package.EntityApiController]: public org.springframework.http.ResponseEntity package.EntityApiController.postEntity() ´´´

openapi-generator version
OpenAPI declaration file content or url

https://gist.github.com/jgarciasm/c9e7a3723678d14ab044cadddcaa522d

Generation Details

It is generated an api with @RequestMapping.value with the 2 media types sepparated by ",". That is an error, should be separated by ";".

Steps to reproduce

Using ´´´org.openapitools.codegen.languages.SpringCodegen´´´. Within any spec place 2 possible responses, both with different media types (as in the example).

Suggest a fix

The problem is being cause because of the "," to separate the 2 media types, it should be ",".

jgarciasm avatar Oct 09 '24 00:10 jgarciasm

Fixed Gist links.

jgarciasm avatar Oct 11 '24 13:10 jgarciasm