swagger-api / swagger-api/swagger-ui

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

Open
#10,650 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the Spring Boot controller and POST, PATCH, and DELETE operations described in the report, then inspect how Swagger UI renders the DELETE operation. Done means the DELETE operation shows no request body unless one is explicitly defined, with a regression test covering the mixed-operation case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.