Skip to content
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

Request Body for Maps not available in Swagger-UI #597

Closed
mburri opened this issue Apr 22, 2020 · 1 comment
Closed

Request Body for Maps not available in Swagger-UI #597

mburri opened this issue Apr 22, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@mburri
Copy link

mburri commented Apr 22, 2020

Describe the bug

Given a ressource that excpects a request body of the following type:
@RequestBody HashMap<String, String> body

The Request Body is not available in the Swagger-UI for the resource since springdoc-openapi-ui 1.3.1
But it works in springdoc-openapi-ui 1.3.0

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    Spring Boot 2.2.6

  • What modules and versions of springdoc-openapi are you using?
    1.3.1 (also tested with 1.3.4 - same issue)

  • What is the actual and the expected result using OpenAPI Description (yml or json)?

the requestbody is not available in the UI - but it should be. The generated api docs is the same for springdoc-openapi-ui 1.3.0 and 1.3.1

  • Provide with a sample code (HelloController) or Test that reproduces the problem
    @PostMapping
    public ResponseEntity<HashMap<String, Object>> hello(@RequestBody HashMap<String, Object> map) {
        return ResponseEntity.ok(map);
    }

Expected behavior

  • A clear and concise description of what you expected to happen.

When trying out the API in Swagger UI - I should be able to pass in the request body.

Screenshots

This is a screenshot of the resource in Swagger-UI with springdoc-openapi-ui v1.3.0:
Request Body available (Version 1.3.0)

This is a screenshot of the resource in Swagger-UI with springdoc-openapi-ui v1.3.1 and above:
Missing Request Body with Version 1.3.1 and above
The section for the request body is missing...
Additional context
none

@bnasslahsen
Copy link
Contributor

bnasslahsen commented Apr 22, 2020

Hi @mburri,

In fact its normal that Maps are ignored:

With v1.3.4, you have a first workaround which is:

static {
	SpringDocUtils.getConfig().removeRequestWrapperToIgnore(java.util.Map.class);
}

For your case, because if you are using @RequestBody spring annotation before the parameter, it shouldn't be ignored as its required by default.
So the behaviour you are expecting will be out of the box, starting from the next release v1.3.5.

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
@springdoc springdoc locked as resolved and limited conversation to collaborators Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants