swagger-api / swagger-api/swagger-codegen

Non-body HTTP method cannot contain @Body

Open
#6,344 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

java.lang.IllegalArgumentException: Non-body HTTP method cannot contain @Body.

Description

generator code
@DELETE("device/flexEng/tenant")
Call deviceFlexEngTenantDelete(
@retrofit2.http.Body FlexEngTenantDeleteParam flexEngTenantDeleteParam
);
Adjust to
@HTTP(method = "DELETE",path = "/device/flexEng/tenant",hasBody = true)
Call deviceFlexEngTenantDelete(
@retrofit2.http.Body FlexEngTenantDeleteParam flexEngTenantDeleteParam
);

Swagger-codegen version

2.2.3 version

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

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 generated Retrofit method shown in the issue with Swagger Codegen 2.2.3 and a DELETE operation containing @Body. Inspect the generator entry point and templates responsible for Retrofit annotations. Done means the generated method uses @HTTP with method="DELETE", the path, and hasBody=true so Retrofit accepts the body.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.