Skip to content

Commit

Permalink
test: Add more different keywords to the test app's /api/payload en…
Browse files Browse the repository at this point in the history
…dpoint
  • Loading branch information
Stranger6667 committed Apr 14, 2020
1 parent 604a7bd commit 1dc48b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/apps/_aiohttp/handlers.py
Expand Up @@ -8,7 +8,7 @@ async def success(request: web.Request) -> web.Response:


async def payload(request: web.Request) -> web.Response:
return web.json_response({"success": await request.json()})
return web.json_response(await request.json())


async def invalid_response(request: web.Request) -> web.Response:
Expand Down
2 changes: 1 addition & 1 deletion test/apps/_flask/__init__.py
Expand Up @@ -45,7 +45,7 @@ def recursive():

@app.route("/api/payload", methods=["POST"])
def payload():
return jsonify({"success": request.json})
return jsonify(request.json)

@app.route("/api/failure", methods=["GET"])
def failure():
Expand Down
37 changes: 23 additions & 14 deletions test/apps/utils.py
Expand Up @@ -56,21 +56,30 @@ def make_schema(endpoints: Tuple[str, ...]) -> Dict:
},
}
elif endpoint == "payload":
schema = {
"parameters": [
{
"name": "body",
"in": "body",
"required": True,
"schema": {
"type": "object",
"properties": {"name": {"type": "string"}},
"required": ["name"],
"example": {"name": "John"},
payload = {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0, "exclusiveMinimum": True},
"boolean": {"type": "boolean"},
"nested": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"exclusiveMinimum": True,
"maximum": 10,
"exclusiveMaximum": True,
},
}
],
"responses": {"200": {"description": "OK"}},
},
},
"required": ["name"],
"example": {"name": "John"},
"additionalProperties": False,
}
schema = {
"parameters": [{"name": "body", "in": "body", "required": True, "schema": payload,}],
"responses": {"200": {"description": "OK", "schema": payload}},
}
elif endpoint == "unsatisfiable":
schema = {
Expand Down

0 comments on commit 1dc48b5

Please sign in to comment.