-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
3,125 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.travis.yaml | ||
.swagger-codegen-ignore | ||
README.md | ||
tox.ini | ||
git_push.sh | ||
test-requirements.txt | ||
setup.py | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
venv/ | ||
.python-version | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
#Ipython Notebook | ||
.ipynb_checkpoints |
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,64 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
venv/ | ||
.python-version | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
#Ipython Notebook | ||
.ipynb_checkpoints |
23 changes: 23 additions & 0 deletions
23
samples/server/petstore/flaskConnexion/.swagger-codegen-ignore
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,23 @@ | ||
# Swagger Codegen Ignore | ||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
1 change: 1 addition & 0 deletions
1
samples/server/petstore/flaskConnexion/.swagger-codegen/VERSION
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 @@ | ||
3.0.9-SNAPSHOT |
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,13 @@ | ||
# ref: https://docs.travis-ci.com/user/languages/python | ||
language: python | ||
python: | ||
- "3.2" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
#- "3.5-dev" # 3.5 development branch | ||
#- "nightly" # points to the latest development branch e.g. 3.6-dev | ||
# command to install dependencies | ||
install: "pip install -r requirements.txt" | ||
# command to run tests | ||
script: nosetests |
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,16 @@ | ||
FROM python:3-alpine | ||
|
||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt /usr/src/app/ | ||
|
||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
|
||
COPY . /usr/src/app | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["python3"] | ||
|
||
CMD ["-m", "swagger_server"] |
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,49 @@ | ||
# Swagger generated server | ||
|
||
## Overview | ||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the | ||
[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This | ||
is an example of building a swagger-enabled Flask server. | ||
|
||
This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask. | ||
|
||
## Requirements | ||
Python 3.5.2+ | ||
|
||
## Usage | ||
To run the server, please execute the following from the root directory: | ||
|
||
``` | ||
pip3 install -r requirements.txt | ||
python3 -m swagger_server | ||
``` | ||
|
||
and open your browser to here: | ||
|
||
``` | ||
http:https://localhost:8080/ui/ | ||
``` | ||
|
||
Your Swagger definition lives here: | ||
|
||
``` | ||
http:https://localhost:8080/swagger.json | ||
``` | ||
|
||
To launch the integration tests, use tox: | ||
``` | ||
sudo pip install tox | ||
tox | ||
``` | ||
|
||
## Running with Docker | ||
|
||
To run the server on a Docker container, please execute the following from the root directory: | ||
|
||
```bash | ||
# building the image | ||
docker build -t swagger_server . | ||
|
||
# starting up a container | ||
docker run -p 8080:8080 swagger_server | ||
``` |
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,52 @@ | ||
#!/bin/sh | ||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ | ||
# | ||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" | ||
|
||
git_user_id=$1 | ||
git_repo_id=$2 | ||
release_note=$3 | ||
|
||
if [ "$git_user_id" = "" ]; then | ||
git_user_id="GIT_USER_ID" | ||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" | ||
fi | ||
|
||
if [ "$git_repo_id" = "" ]; then | ||
git_repo_id="GIT_REPO_ID" | ||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" | ||
fi | ||
|
||
if [ "$release_note" = "" ]; then | ||
release_note="Minor update" | ||
echo "[INFO] No command line input provided. Set \$release_note to $release_note" | ||
fi | ||
|
||
# Initialize the local directory as a Git repository | ||
git init | ||
|
||
# Adds the files in the local repository and stages them for commit. | ||
git add . | ||
|
||
# Commits the tracked changes and prepares them to be pushed to a remote repository. | ||
git commit -m "$release_note" | ||
|
||
# Sets the new remote | ||
git_remote=`git remote` | ||
if [ "$git_remote" = "" ]; then # git remote not defined | ||
|
||
if [ "$GIT_TOKEN" = "" ]; then | ||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." | ||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git | ||
else | ||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git | ||
fi | ||
|
||
fi | ||
|
||
git pull origin master | ||
|
||
# Pushes (Forces) the changes in the local repository up to the remote repository | ||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" | ||
git push origin master 2>&1 | grep -v 'To https' | ||
|
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,3 @@ | ||
connexion == 2.2.0 | ||
python_dateutil == 2.6.0 | ||
setuptools >= 21.0.0 |
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,33 @@ | ||
# coding: utf-8 | ||
|
||
import sys | ||
from setuptools import setup, find_packages | ||
|
||
NAME = "swagger_server" | ||
VERSION = "1.0.0" | ||
# To install the library, run the following | ||
# | ||
# python setup.py install | ||
# | ||
# prerequisite: setuptools | ||
# http:https://pypi.python.org/pypi/setuptools | ||
|
||
REQUIRES = ["connexion"] | ||
|
||
setup( | ||
name=NAME, | ||
version=VERSION, | ||
description="Swagger Petstore", | ||
author_email="[email protected]", | ||
url="", | ||
keywords=["Swagger", "Swagger Petstore"], | ||
install_requires=REQUIRES, | ||
packages=find_packages(), | ||
package_data={'': ['swagger/swagger.yaml']}, | ||
include_package_data=True, | ||
entry_points={ | ||
'console_scripts': ['swagger_server=swagger_server.__main__:main']}, | ||
long_description="""\ | ||
This is a sample Petstore server. You can find out more about Swagger at [http:https://swagger.io](http:https://swagger.io) or on [irc.freenode.net, #swagger](http:https://swagger.io/irc/). | ||
""" | ||
) |
Empty file.
16 changes: 16 additions & 0 deletions
16
samples/server/petstore/flaskConnexion/swagger_server/__main__.py
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,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import connexion | ||
|
||
from swagger_server import encoder | ||
|
||
|
||
def main(): | ||
app = connexion.App(__name__, specification_dir='./swagger/') | ||
app.app.json_encoder = encoder.JSONEncoder | ||
app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'}, pythonic_params=True) | ||
app.run(port=8080) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
18 changes: 18 additions & 0 deletions
18
...les/server/petstore/flaskConnexion/swagger_server/controllers/authorization_controller.py
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,18 @@ | ||
from typing import List | ||
""" | ||
controller generated to handled auth operation described at: | ||
https://connexion.readthedocs.io/en/latest/security.html | ||
""" | ||
def check_api_key(api_key, required_scopes): | ||
return {'test_key': 'test_value'} | ||
|
||
def check_bearer(token): | ||
return {'test_key': 'test_value'} | ||
|
||
def check_petstore_auth(token): | ||
return {'scopes': ['read:pets', 'write:pets'], 'uid': 'test_value'} | ||
|
||
def validate_scope_petstore_auth(required_scopes, token_scopes): | ||
return set(required_scopes).issubset(set(token_scopes)) | ||
|
||
|
Oops, something went wrong.