-
Notifications
You must be signed in to change notification settings - Fork 359
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
when use prism proxy - GET/HEAD can't have body error #1408
Comments
Mind if I ask why GET or HEAD has a body? :)
|
Yeah same here — this is something we really advice not to do. I'm closing this since it's the behaviour we want; we can keep the conversation going on if you think it's beneficial. |
Not sure why this has been closed . I am not sending any requestbody with get method
. It works with mock servers but not with real api when use proxy command
Sent from my iPhone
… On 12 Sep 2020, at 4:50 am, Vincenzo Chianese ***@***.***> wrote:
Closed #1408.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@ram-potla For some reason I've missed the message. From the error message, it looks that you're sending a body with a GET request; the example you provided is not well formatted and I struggle to reproduce the issue. If you could set up a better scenario, I can take a look into. Cheers! |
The Python generator no longer sets a default `Content-Type` of `application/json` for `GET`, `HEAD` and `DELETE` requests. Having the `Content-Type` set for these requests was causing issues with other tools which insist that GET, HEAD and DELETE requests do not have a Content-Type (as per the OpenAPI 3 specification). An example of the problem that this commit fixes is when using [Prism][1] as a [validation proxy][2]. [Prism rejects any GET request that has a Content-Type][3]. Here is [an example of the problem manifesting itself][4]. To validate the fix in this commit: 1. Start with any OpenAPI3 spec e.g. the Petstore example at https://editor.swagger.io/ 2. Generate Python client code for the spec 3. Look at the generated `rest.py` e.g. in the [standard sample in this repo][5] and see that the `Content-Type` defaults to `application/json` for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than there being no `Content-Type` for `GET`, `HEAD` and `DELETE`. Fixes OpenAPITools#9831 [1]: https://github.com/stoplightio/prism [2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md [3]: stoplightio/prism#1408 (comment) [4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18 [5]: https://github.com/OpenAPITools/openapi-generator/blob/969cea8ce10cb9d012c3936fb377d631c0d044c9/samples/openapi3/client/petstore/python/petstore_api/rest.py#L141
#9852) * [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests The Python generator no longer sets a default `Content-Type` of `application/json` for `GET`, `HEAD` and `DELETE` requests. Having the `Content-Type` set for these requests was causing issues with other tools which insist that GET, HEAD and DELETE requests do not have a Content-Type (as per the OpenAPI 3 specification). An example of the problem that this commit fixes is when using [Prism][1] as a [validation proxy][2]. [Prism rejects any GET request that has a Content-Type][3]. Here is [an example of the problem manifesting itself][4]. To validate the fix in this commit: 1. Start with any OpenAPI3 spec e.g. the Petstore example at https://editor.swagger.io/ 2. Generate Python client code for the spec 3. Look at the generated `rest.py` e.g. in the [standard sample in this repo][5] and see that the `Content-Type` defaults to `application/json` for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than there being no `Content-Type` for `GET`, `HEAD` and `DELETE`. Fixes #9831 [1]: https://github.com/stoplightio/prism [2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md [3]: stoplightio/prism#1408 (comment) [4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18 [5]: https://github.com/OpenAPITools/openapi-generator/blob/969cea8ce10cb9d012c3936fb377d631c0d044c9/samples/openapi3/client/petstore/python/petstore_api/rest.py#L141 * update samples * Fix Python DELETE bug introduced in earlier commit The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the standard Python generator. This commit fixes that bug and also includes the updated samples. Co-authored-by: William Cheng <[email protected]>
…s (#9852) * [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests The Python generator no longer sets a default `Content-Type` of `application/json` for `GET`, `HEAD` and `DELETE` requests. Having the `Content-Type` set for these requests was causing issues with other tools which insist that GET, HEAD and DELETE requests do not have a Content-Type (as per the OpenAPI 3 specification). An example of the problem that this commit fixes is when using [Prism][1] as a [validation proxy][2]. [Prism rejects any GET request that has a Content-Type][3]. Here is [an example of the problem manifesting itself][4]. To validate the fix in this commit: 1. Start with any OpenAPI3 spec e.g. the Petstore example at https://editor.swagger.io/ 2. Generate Python client code for the spec 3. Look at the generated `rest.py` e.g. in the [standard sample in this repo][5] and see that the `Content-Type` defaults to `application/json` for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than there being no `Content-Type` for `GET`, `HEAD` and `DELETE`. Fixes #9831 [1]: https://github.com/stoplightio/prism [2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md [3]: stoplightio/prism#1408 (comment) [4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18 [5]: https://github.com/OpenAPITools/openapi-generator/blob/969cea8ce10cb9d012c3936fb377d631c0d044c9/samples/openapi3/client/petstore/python/petstore_api/rest.py#L141 * update samples * Fix Python DELETE bug introduced in earlier commit The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the standard Python generator. This commit fixes that bug and also includes the updated samples. Co-authored-by: William Cheng <[email protected]>
…s (#9852) * [BUG][PYTHON] Do not set Content-Type for GET, HEAD or DELETE requests The Python generator no longer sets a default `Content-Type` of `application/json` for `GET`, `HEAD` and `DELETE` requests. Having the `Content-Type` set for these requests was causing issues with other tools which insist that GET, HEAD and DELETE requests do not have a Content-Type (as per the OpenAPI 3 specification). An example of the problem that this commit fixes is when using [Prism][1] as a [validation proxy][2]. [Prism rejects any GET request that has a Content-Type][3]. Here is [an example of the problem manifesting itself][4]. To validate the fix in this commit: 1. Start with any OpenAPI3 spec e.g. the Petstore example at https://editor.swagger.io/ 2. Generate Python client code for the spec 3. Look at the generated `rest.py` e.g. in the [standard sample in this repo][5] and see that the `Content-Type` defaults to `application/json` for all HTTP methods (including `GET`, `HEAD` and `DELETE`), rather than there being no `Content-Type` for `GET`, `HEAD` and `DELETE`. Fixes #9831 [1]: https://github.com/stoplightio/prism [2]: https://meta.stoplight.io/docs/prism/docs/guides/03-validation-proxy.md [3]: stoplightio/prism#1408 (comment) [4]: https://github.com/agilepathway/gauge-openapi-example/pull/28/checks?check_run_id=2888606052#step:13:18 [5]: https://github.com/OpenAPITools/openapi-generator/blob/969cea8ce10cb9d012c3936fb377d631c0d044c9/samples/openapi3/client/petstore/python/petstore_api/rest.py#L141 * update samples * Fix Python DELETE bug introduced in earlier commit The earlier commit 9dfe1f6 introduced a bug for `DELETE` requests on the standard Python generator. This commit fixes that bug and also includes the updated samples. Co-authored-by: William Cheng <[email protected]>
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
1 .feed openspec to prism
2. run prism mock severs
3. get response ok as per spec.
I see below error.
{
“type”: “TypeError”,
“title”: “Request with GET/HEAD method cannot have body”,
“status”: 500,
“detail”: “”
}
Environment:
spec: openapi: 3.0.1
info:
title: dfdfsdfdf
license:
name: Apache 2.0
url: http://springdoc.org
version: 1.4.6
servers:
description: Generated server url
tags:
description: description
paths:
/api/v1/employees:
get:
tags:
- employee
summary: employees
description: Fetches all engineers from db
operationId: fetchAll
parameters:
- name: Content-Type
in: header
required: false
schema:
type: string
default: application/json
- name: Accept
in: header
required: true
schema:
type: string
- name: X-type
in: header
required: true
schema:
type: string
responses:
"200":
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Employee'
The text was updated successfully, but these errors were encountered: