Skip to content

DELETE endpoint incorrectly shows request body model in Swagger UI even when no request body exists #10650

@Calil13

Description

@Calil13

Description:

Hello Swagger UI team,

I have encountered a UI bug in Swagger UI when documenting Spring Boot REST controllers.

When a controller contains multiple operations under the same path prefix — for example:

POST /category (with request body)

PATCH /category/{id} (with request body)

DELETE /category/{id} (no request body)

Swagger UI incorrectly displays a request body schema for the DELETE endpoint, even though the endpoint does not accept any request body in Spring.

This leads Swagger UI to generate an incorrect example, such as:

{
"id": 9007199254740991,
"name": "string",
"subCategory": ["string"]
}

But the real endpoint is:

@DeleteMapping("/category/admin/{id}")
public void deleteCategory(@PathVariable Long id) {
categoryService.deleteCategory(id);
}

Expected behavior:

Swagger UI should not display any request body for DELETE methods unless explicitly defined with @RequestBody.

Actual behavior:

Swagger UI incorrectly displays a JSON request body model inherited from other operations in the controller.

Steps to reproduce:

Create a Spring Boot controller containing both POST/PATCH with request body and DELETE without body:

@RestController
@RequestMapping("/category")
public class CategoryController {

@PostMapping
public void create(@RequestBody CategoryDto dto) { }

@PatchMapping("/{id}")
public void update(@PathVariable Long id, @RequestBody CategoryDto dto) { }

@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) { }

}

Open Swagger UI

Observe that the DELETE operation shows a request body model even though none is defined.

Environment:

Spring Boot 3.x

springdoc-openapi-starter-webmvc-ui 2.x

Java 17+

Swagger UI version bundled with springdoc

Additional info:

This seems to be a rendering issue in Swagger UI, not in OpenAPI itself.
Postman and other tools correctly show that DELETE does not have a request body.

A fix for ignoring inherited schemas for DELETE operations would be appreciated.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions