Skip to content

Commit

Permalink
Add test for request body in GET
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwann committed Oct 21, 2023
1 parent 13022ea commit aea2759
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/api/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ def test_body_not_allowed_additional_properties(simple_app):
assert "Additional properties are not allowed" in response["detail"]


def test_body_in_get_request(simple_app):
app_client = simple_app.test_client()
body = {"body1": "bodyString"}
resp = app_client.request(
"GET",
"/v1.0/body-in-get-request",
json=body,
)
assert resp.status_code == 200
assert resp.json() == body


def test_bool_as_default_param(simple_app):
app_client = simple_app.test_client()
resp = app_client.get("/v1.0/test-bool-param")
Expand Down
4 changes: 4 additions & 0 deletions tests/fakeapi/hello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ def test_body_not_allowed_additional_properties(body):
return body


def test_body_in_get_request(body):
return body


def post_wrong_content_type():
return "NOT OK"

Expand Down
14 changes: 14 additions & 0 deletions tests/fixtures/simple/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,20 @@ paths:
body1:
type: string
additionalProperties: false
/body-in-get-request:
get:
operationId: fakeapi.hello.test_body_in_get_request
responses:
'200':
description: OK
requestBody:
content:
application/json:
schema:
type: object
properties:
body1:
type: string
/get_non_conforming_response:
get:
operationId: fakeapi.hello.get_empty_dict
Expand Down
21 changes: 21 additions & 0 deletions tests/fixtures/simple/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,27 @@ paths:
200:
description: OK

/body-in-get-request:
get:
operationId: fakeapi.hello.test_body_in_get_request
consumes:
- application/json
produces:
- application/json
parameters:
- name: $body
description: A request body in a GET method.
in: body
required: true
schema:
type: object
properties:
body1:
type: string
responses:
200:
description: OK

/get_non_conforming_response:
get:
operationId: fakeapi.hello.get_empty_dict
Expand Down

0 comments on commit aea2759

Please sign in to comment.