Skip to content

Request body description not shown #2703

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
muzuro opened this issue Sep 11, 2024 · 1 comment · Fixed by #2727
Closed

Request body description not shown #2703

muzuro opened this issue Sep 11, 2024 · 1 comment · Fixed by #2727

Comments

@muzuro
Copy link

muzuro commented Sep 11, 2024

I have created controller with optional RequestBody. I added RequestBody but description not shown in the generated Swagger UI.

Controller snippet:

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RestController
import java.util.UUID

@RestController
class HelloController {

    @PostMapping("/hello")
    @Operation(summary = "Say hello",
        requestBody = io.swagger.v3.oas.annotations.parameters.RequestBody(
            description = "Map uid -> string)",
            required = false
        ),
        responses = [
            ApiResponse(responseCode = "200", description = "Ok"),
        ])
    fun hello(@RequestBody(required = false) body: Map<UUID, String>?): ResponseEntity<*> {
        return ResponseEntity.ok().build<Any>()
    }
    
}

How Swagger UI looks:
image

Actual OpenAPI Description json:
hello":{"post":{"tags":["hello-controller"],"summary":"Say hello","operationId":"hello","requestBody":{"description":"Map uid -> string)"},"responses":{"200":{"description":"Ok","content":{"*/*":{"schema":{"type":"object"}}}}}}},

Expected behavior:
Request body shown

Actual behavior:
Request body not shown

Spring boot: 3.2.2
Spring doc: 2.6.0

@ShahrearBinAmin
Copy link

Facing the same issue, please fix it. Otherwise, it becomes hard to communicate with the frontend developers.

granddaifuku added a commit to granddaifuku/springdoc-openapi that referenced this issue Sep 27, 2024
granddaifuku added a commit to granddaifuku/springdoc-openapi that referenced this issue Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants