Skip to content

Discovery of MediaType producers inconsistent with Spring MVC behaviour #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dominic-jones opened this issue Feb 14, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@dominic-jones
Copy link

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.

@bnasslahsen
Copy link
Collaborator

Hi @dominic-jones,

The fix will be available on v1.2.31.

@dominic-jones
Copy link
Author

Excellent, thank you for the speedy fix! It is working as I expect here.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants