forked from spec-first/connexion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into return_tuple_for_aiohttp
- Loading branch information
Showing
36 changed files
with
170 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
======================= | ||
API Key Example | ||
======================= | ||
|
||
Running: | ||
|
||
.. code-block:: bash | ||
$ sudo pip3 install --upgrade connexion[swagger-ui] # install Connexion from PyPI | ||
$ ./app.py | ||
Now open your browser and go to http://localhost:8080/ui/ to see the Swagger UI. | ||
|
||
The hardcoded apikey is `asdf1234567890`. | ||
|
||
Test it out (in another terminal): | ||
|
||
.. code-block:: bash | ||
$ curl -H 'X-Auth: asdf1234567890' http://localhost:8080/secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
''' | ||
Basic example of a resource server | ||
''' | ||
|
||
import connexion | ||
from connexion.exceptions import OAuthProblem | ||
|
||
TOKEN_DB = { | ||
'asdf1234567890': { | ||
'uid': 100 | ||
} | ||
} | ||
|
||
|
||
def apikey_auth(token, required_scopes): | ||
info = TOKEN_DB.get(token, None) | ||
|
||
if not info: | ||
raise OAuthProblem('Invalid token') | ||
|
||
return info | ||
|
||
|
||
def get_secret(user) -> str: | ||
return "You are {user} and the secret is 'wbevuec'".format(user=user) | ||
|
||
|
||
if __name__ == '__main__': | ||
app = connexion.FlaskApp(__name__) | ||
app.add_api('openapi.yaml') | ||
app.run(port=8080) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: API Key Example | ||
version: '1.0' | ||
paths: | ||
/secret: | ||
get: | ||
summary: Return secret string | ||
operationId: app.get_secret | ||
responses: | ||
'200': | ||
description: secret response | ||
content: | ||
'*/*': | ||
schema: | ||
type: string | ||
security: | ||
- api_key: [] | ||
components: | ||
securitySchemes: | ||
api_key: | ||
type: apiKey | ||
name: X-Auth | ||
in: header | ||
x-apikeyInfoFunc: app.apikey_auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import asyncio | ||
import base64 | ||
|
||
|
||
from connexion import AioHttpApp | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import sys | ||
|
||
import pytest | ||
|
||
from connexion import App | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.