Skip to content

[BUG] [sprind-cloud] Multiple response bodies generates invalid code #8700

Description

@MelleD
Description

If multiple response bodies are specified, the producer annotation is filled incorrectly and a spring boot application cannot be started.

openapi-generator version

4.3.1 and 5.0.1

OpenAPI declaration file content or url
  /foo:
    post:
      operationId: createFoo
      ...
      responses:
        '200':
          description: "Return"
          content:
                    text/plain:
                      schema:
                        type: string
                    text/html:
                      schema:
                        type: string

Generated java code

@RequestMapping(produces = "text/plain,text/html")
public ResponseEntity<Void> createFoo(...) {...}
Generation Details

Maven plugin

      <configuration>
                            <generatorName>spring</generatorName>
                            <configOptions>
                                <sortParamsByRequiredFlag>true</sortParamsByRequiredFlag>
                                <library>spring-cloud</library>
                                <java8>true</java8>
                                <dateLibrary>java8</dateLibrary>
                                <useOptional>true</useOptional>
                                <skipDefaultInterface>true</skipDefaultInterface>
                                <useBeanValidation>true</useBeanValidation>
                            </configOptions>
Steps to reproduce

Use multiple response bodies:

Expected code is not a comma separated String. Spring needs a proper list of producers

@RequestMapping(produces = {"text/plain","text/html"})
public ResponseEntity<Void> createFoo(...) {...}

see https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html#produces--

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions