Skip to content

[fix included] produces / consumes mapping is generated multiple times #126

Closed
@JonasGroeger

Description

@JonasGroeger

There must be a distinct filter applied to the produces and consumes mappings since otherwise it generates the following structure:

    @GetMapping(
            path = "/destinations",
            produces = {
                "application/json",
                "application/json",
                "application/json",
                "application/json"
            })
    ResponseEntity<?> getAllDestinations();

from this yaml:

paths:
    '/destinations':
        get:
            responses:
                '200':
                    description: OK
                    content:
                        application/json:
                            schema:
                                '$ref': '#/components/schemas/GetAllDestinationsResponse'
                '400':
                    description: Bad Request
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/ErrorResponse'
                '401':
                    description: Unauthorized
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/ErrorResponse'
                '403':
                    description: Forbidden
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/ErrorResponse'

Fix:

mapping +=  consumes.map {
    quote(it)
}.distinct().joinToString(", ")

mapping +=  produces.map {
    quote(it)
}.distinct().joinToString(", ")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions