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

Explicitly support Flask async routes #1592

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def read_version(package):
swagger_ui_require = 'swagger-ui-bundle>=0.0.2,<0.1'

flask_require = [
'flask>=2.2,<3',
'flask[async]>=2.2,<3',
'a2wsgi>=1.4,<2',
]

Expand Down
6 changes: 6 additions & 0 deletions tests/api/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,9 @@ def test_using_all_fields_in_path_item(simple_api_spec_dir):
continue
test_methods.update({method.lower() for method in rule.methods})
assert set(test_methods) == METHODS


def test_async_route(simple_app):
app_client = simple_app.app.test_client()
resp = app_client.get("/v1.0/async-route")
assert resp.status_code == 200
4 changes: 4 additions & 0 deletions tests/fakeapi/hello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,7 @@ def nullable_default(test):

def get_streaming_response():
return send_file(__file__)


async def async_route():
return {}, 200
7 changes: 7 additions & 0 deletions tests/fixtures/simple/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,13 @@ paths:
responses:
'200':
description: Echo the validated request.
/async-route:
get:
operationId: fakeapi.hello.async_route
responses:
200:
description: 'OK'


servers:
- url: http://localhost:{port}/{basePath}
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/simple/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,13 @@ paths:
schema:
type: file

/async-route:
get:
operationId: fakeapi.hello.async_route
responses:
200:
description: 'OK'

definitions:
new_stack:
type: object
Expand Down