Skip to content
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

GET request do not allow a body #5388

Closed
dominikzogg opened this issue Jun 5, 2019 · 16 comments
Closed

GET request do not allow a body #5388

dominikzogg opened this issue Jun 5, 2019 · 16 comments

Comments

@dominikzogg
Copy link

Q&A (please complete the following information)

  • OS: linux
  • Browser: firefox
  • Version: 67
  • Method of installation: composer
  • Swagger-UI version: 3.20.7
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: "3.0.0"
servers:
  - url: https://myproject.development
paths:
  /search-by-email:
    get:
      requestBody:
        description: get info by email address
        required: true
        content:
          application/json:
            schema:
              type: object   
              properties:
                email:
                  type: string
                  example: john.doe@gmail.com

Describe the bug you're encountering

As far as i understand the http specs, sending a body is also valid in a GET call.
Cause E-Mail Addresses are privacy relevant, we don't like to have it in the URL (as path part or query parameter).

This endpoint does not modify anything, so POST is not a correct method to do so.

@pavlus
Copy link

pavlus commented Jun 24, 2019

https://tools.ietf.org/html/rfc7231#section-4.3.1 :

A payload within a GET request message has no defined semantics;
sending a payload body on a GET request might cause some existing
implementations to reject the request.

@dominikzogg
Copy link
Author

@pavlus as far as i understand this, this mean that a server does not need to implement this, not that the spec forbits it. So if the backend application is been able to do it, its ok todo so.

@shockey
Copy link
Contributor

shockey commented Jun 24, 2019

@dominikzogg, we've had a lot of discussion around this.

most of all, you should pay attention to what happens in OAI/OpenAPI-Specification#1937, as it's looking like OpenAPI 3.0.3 could support your use case.

for now, Swagger UI doesn't support this, because we're waiting on OpenAPI to make a final decision and release a new version of the specification. the tickets I've linked to contain, probably, more info than you care to know about why we do things that way 😄

closing for now -- let me know if you have any lingering questions!

@shockey shockey closed this as completed Jun 24, 2019
@dominikzogg
Copy link
Author

@shockey thanks for the additional information, issue at this level is solved so far

@niulin
Copy link

niulin commented Jun 27, 2019

Apparently, If swagger sticks to the OpenAPI standard, we should avoid using swagger with Spring MVC, since Spring MVC allows GET request with a body.
If Swagger does not allow this, we have to seek alternatives, either Swagger or Spring MVC. Given we already have so many applications running in production, it's unlikely we replace the application framework, we have to replace Swagger.

@tseale07
Copy link

Has there been any follow up on this? OpenAPI did end up allowing a request body on GET requests. Should this be re-opened?

@miraculixx
Copy link

miraculixx commented Nov 26, 2020

Has there been any follow up on this? OpenAPI did end up allowing a request body on GET requests

Indeed, see OAI/OpenAPI-Specification#2117

IMHO this issue should be reopened to keep in line with the OpenAPI specs.

@mehulchandroliya
Copy link

Yes Please reopen

@dimos171
Copy link

using .NET swashbuckle.AspNetCore.SwaggerUI 6.2.2 and have the same error.
please reopen

@evgenisokolov
Copy link

I'm also voting for reopening this since it's becoming quite common to use get requests with body

@labeled
Copy link

labeled commented Oct 15, 2021

+1

5 similar comments
@vikumar-ciena
Copy link

+1

@okohub
Copy link

okohub commented Oct 19, 2022

+1

@diogo-correia-tec
Copy link

+1

@christophe-taret-zenika
Copy link

+1

@hoylu-royberg
Copy link

+1

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

No branches or pull requests