question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Message "DELETE operations cannot have a requestBody" appears on a previously OK specification.

See original GitHub issue

On 2018/04/08, the v3.0 specification I had worked was not shown as having errors in SwaggerHub. The following morning, 2018/04/09, immediately upon opening the specification the error message appeared saying “DELETE operations cannot have a requestBody”.

The API I was working indeed is a DELETE method having a request payload. So the error message is correct. However, several servers accept a payload with a delete method, and on the previous months this API was being documented using SwaggerHub, no such error message was displayed.

So I am wondering if SwaggerHub was updated sometime between Sunday afternoon PST on 4/8 and Monday morning PST on 4/9. And if so, is there a conscious attempt to more rigorously enforce a standard that doesn’t permit a payload to accompany a DELETE request?

I’ve cross checked yesterday’s work by copying the last commit I made into the SwaggerHub editor. The error message appears, while at the same time yesterday’s work shows up fine on my testing server. Thus I am sure I did not introduce a change to the API file in SwaggerHub after finishing yesterday.

I created a smaller API specification on SwaggerHub that demonstrates the error I am seeing. https://app.swaggerhub.com/apis/mikefidel/BUG-Delete-Method-Having-RequestBody/1.0.0

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0
Which Swagger-UI version? current SwaggerHub version
How did you install Swagger-UI? problem does not occur in v3.13.0 which is used for testing
Which browser & version? Chrome latest
Which operating system? Windows 10

Demonstration API definition

Found at SwaggerHub []https://app.swaggerhub.com/apis/mikefidel/BUG-Delete-Method-Having-RequestBody/1.0.0)

openapi: 3.0.0
info:
  version: '1.0.0'
  title: 'Bug-Delete-Method-Has-RequestBody'
  description: "On 2018/04/08  SwaggerHub considered this acceptable.  Today (2018/04/09) an error message is displayed saying DELETE operations cannot have a requestBody."
servers:
  - url: http://test.ndexbio.org/v2
    description: "NDEx test server"

paths:
  /networkset/members:
    delete:
      summary: Delete Networks from Network Set
      requestBody:
        content:
          application/json:
            schema:
              type: array
              description: "List of networks belonging to this network set"
              items:
                type: string
                format: uuid
                description: "Network object UUID"
        example: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      responses:
        500-response:
          description: "Sloppy cut-paste - ignore this response"

Expected Behavior

No error message appears.

Current Behavior

Error message appears.

Possible Solution

Not upgrading to Swagger-UI releases after 3,13,0.

Context

As the error does not appear on our older 3.13.0 test system, we’ll not be upgrading to later versions.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:36 (11 by maintainers)

github_iconTop GitHub Comments

36reactions
adjenkscommented, Jan 8, 2019

My API has a request body for a DELETE operation and I believe the design is logical and useful and do not want to be constrained by the fact that there is no “explicitly defined semantics” for the DELETE request body. I would like this to be supported. This would have to start with the OpenAPI specification though, so I have opened a ticket there: https://github.com/OAI/OpenAPI-Specification/issues/1801

26reactions
ABSAhmadcommented, May 6, 2021

I just ran into the same issue, it seems like 3.1.0 has been released. Are there any plans to update swagger-ui to support that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger openApi Spec 3.0 - DELETE operation
No, you cannot use the OpenAPI 3.0 Specification and Swagger tools to implement DELETE requests with a request body.
Read more >
Bug: "Delete operations cannot have a requestBody...
I'm using Swagger/OAS3 to document our existing API. When I document the DELETE method in one endpoint I get the following message:
Read more >
Request for guidance on OpenAPI disallowing DELETE with ...
Allow requestBody for the DELETE method.​​ Currently the OpenAPI spec says "The requestBody is only supported in HTTP methods where the HTTP 1.1...
Read more >
Describing Request Body - Swagger
Request bodies are typically used with “create” and “update” operations (POST ... GET, DELETE and HEAD are no longer allowed to have request...
Read more >
Solved: Request Body not getting rendered for delete reque...
I tried generating smartdocs from the OpenApiSpecs. The issue is, there is no sample body getting generated for the requests with verb as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found