Skip to content

Discovery of MediaType producers inconsistent with Spring MVC behaviour #426

Closed
@dominic-jones

Description

@dominic-jones

Describe the bug
When produces is not defined at a Controller method level, the Controller class level one is used instead.

Say

@RequestMapping(value = "/api/v1/addresses", produces = APPLICATION_JSON_VALUE)
@RestController
public class AddressResource {
    @GetMapping
    public AddressDto getAddress(@PathVariable String id) {
        ...

I would expect Spring to produce json for this method.

However, Springdoc has, instead of inherited the parent, it has merged class and method (choosing a default for the method - MediaTypes.ALL).

Resulting in

content": {
    "*/*": {
        "schema": {
            "$ref": "#/components/schemas/AddressDto"
        }
    },
    "application/json": {
        "schema": {
            "$ref": "#/components/schemas/AddressDto"
        }
    }
}

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    2.2.4-RELEASE

  • What modules and versions of springdoc-openapi are you using?
    1.2.30, no additional modules (ui, common, webmvccore)

Expected behavior
I would expect only json as a result, not ALL + json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions