Skip to content

Commit e9c145b

Browse files
committed
initial openapi generated flask app. tests will fail
1 parent 4d98b48 commit e9c145b

27 files changed

Lines changed: 1414 additions & 0 deletions

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: 2.1
2+
3+
orbs:
4+
# The node orb contains a set of prepackaged circleci configuration you can use
5+
# Orbs commands and jobs help you with common scripting around a language/tool
6+
# so you dont have to copy and paste it everywhere.
7+
python: circleci/python@1.2
8+
9+
workflows:
10+
sample:
11+
jobs:
12+
- build-and-test
13+
14+
jobs:
15+
build-and-test:
16+
docker:
17+
# Be sure to change this to major.minor version of python you need to support.
18+
- image: cimg/python:3.9
19+
# Checkout the code as the first step.
20+
# The python orb's install-packages step will install the dependencies from a Pipfile via Pipenv by default.
21+
# Here we're making sure we just pip by default
22+
# Then run your tests!
23+
# CircleCI will report the results back to your VCS provider.
24+
steps:
25+
- checkout
26+
- python/install-packages:
27+
pkg-manager: pip
28+
- run:
29+
name: Run tests
30+
command: pytest
31+

.dockerignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
.travis.yaml
2+
.openapi-generator-ignore
3+
README.md
4+
tox.ini
5+
git_push.sh
6+
test-requirements.txt
7+
setup.py
8+
9+
# Byte-compiled / optimized / DLL files
10+
__pycache__/
11+
*.py[cod]
12+
*$py.class
13+
14+
# C extensions
15+
*.so
16+
17+
# Distribution / packaging
18+
.Python
19+
env/
20+
build/
21+
develop-eggs/
22+
dist/
23+
downloads/
24+
eggs/
25+
.eggs/
26+
lib/
27+
lib64/
28+
parts/
29+
sdist/
30+
var/
31+
*.egg-info/
32+
.installed.cfg
33+
*.egg
34+
35+
# PyInstaller
36+
# Usually these files are written by a python script from a template
37+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
38+
*.manifest
39+
*.spec
40+
41+
# Installer logs
42+
pip-log.txt
43+
pip-delete-this-directory.txt
44+
45+
# Unit test / coverage reports
46+
htmlcov/
47+
.tox/
48+
.coverage
49+
.coverage.*
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
*,cover
54+
.hypothesis/
55+
venv/
56+
.python-version
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
65+
# Sphinx documentation
66+
docs/_build/
67+
68+
# PyBuilder
69+
target/
70+
71+
#Ipython Notebook
72+
.ipynb_checkpoints

.openapi-generator-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3-alpine
2+
3+
RUN mkdir -p /usr/src/app
4+
WORKDIR /usr/src/app
5+
6+
COPY requirements.txt /usr/src/app/
7+
8+
RUN pip3 install --no-cache-dir -r requirements.txt
9+
10+
COPY . /usr/src/app
11+
12+
EXPOSE 8080
13+
14+
ENTRYPOINT ["python3"]
15+
16+
CMD ["-m", "openapi_server"]

git_push.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3+
#
4+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
5+
6+
git_user_id=$1
7+
git_repo_id=$2
8+
release_note=$3
9+
git_host=$4
10+
11+
if [ "$git_host" = "" ]; then
12+
git_host="github.com"
13+
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14+
fi
15+
16+
if [ "$git_user_id" = "" ]; then
17+
git_user_id="GIT_USER_ID"
18+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19+
fi
20+
21+
if [ "$git_repo_id" = "" ]; then
22+
git_repo_id="GIT_REPO_ID"
23+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24+
fi
25+
26+
if [ "$release_note" = "" ]; then
27+
release_note="Minor update"
28+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29+
fi
30+
31+
# Initialize the local directory as a Git repository
32+
git init
33+
34+
# Adds the files in the local repository and stages them for commit.
35+
git add .
36+
37+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
38+
git commit -m "$release_note"
39+
40+
# Sets the new remote
41+
git_remote=`git remote`
42+
if [ "$git_remote" = "" ]; then # git remote not defined
43+
44+
if [ "$GIT_TOKEN" = "" ]; then
45+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46+
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47+
else
48+
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
49+
fi
50+
51+
fi
52+
53+
git pull origin master
54+
55+
# Pushes (Forces) the changes in the local repository up to the remote repository
56+
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57+
git push origin master 2>&1 | grep -v 'To https'
58+

openapi_server/__init__.py

Whitespace-only changes.

openapi_server/__main__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
3+
import connexion
4+
5+
from openapi_server import encoder
6+
7+
8+
def main():
9+
app = connexion.App(__name__, specification_dir='./openapi/')
10+
app.app.json_encoder = encoder.JSONEncoder
11+
app.add_api('openapi.yaml',
12+
arguments={'title': 'ZoomFoodToo'},
13+
pythonic_params=True)
14+
app.run(port=8080)
15+
16+
17+
if __name__ == '__main__':
18+
main()

openapi_server/controllers/__init__.py

Whitespace-only changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import connexion
2+
import six
3+
4+
from openapi_server.models.cart import Cart # noqa: E501
5+
from openapi_server.models.error import Error # noqa: E501
6+
from openapi_server.models.menu_item import MenuItem # noqa: E501
7+
from openapi_server import util
8+
9+
10+
def add_cart_item(menu_item): # noqa: E501
11+
"""Add a menu item a cart
12+
13+
Creates a new item in the cart. Duplicates are allowed # noqa: E501
14+
15+
:param menu_item: Item to add to the cart
16+
:type menu_item: dict | bytes
17+
18+
:rtype: None
19+
"""
20+
if connexion.request.is_json:
21+
menu_item = MenuItem.from_dict(connexion.request.get_json()) # noqa: E501
22+
return 'do some magic!'
23+
24+
25+
def delete_cart_item(item_id): # noqa: E501
26+
"""Remove item from cart
27+
28+
The item must be in the cart. If multiple of same item, call this twice # noqa: E501
29+
30+
:param item_id: The menu item to delete from cart
31+
:type item_id: int
32+
33+
:rtype: None
34+
"""
35+
return 'do some magic!'
36+
37+
38+
def list_cart(limit=None): # noqa: E501
39+
"""List all cart items
40+
41+
# noqa: E501
42+
43+
:param limit: How many items to return at one time (max 100)
44+
:type limit: int
45+
46+
:rtype: Cart
47+
"""
48+
return 'do some magic!'
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import connexion
2+
import six
3+
4+
from openapi_server.models.error import Error # noqa: E501
5+
from openapi_server.models.menu_item import MenuItem # noqa: E501
6+
from openapi_server import util
7+
8+
9+
def add_menu_item(menu_item): # noqa: E501
10+
"""Create a menu item
11+
12+
Creates a new item in the menu. Duplicates are allowed # noqa: E501
13+
14+
:param menu_item: Item to add to the store
15+
:type menu_item: dict | bytes
16+
17+
:rtype: None
18+
"""
19+
if connexion.request.is_json:
20+
menu_item = MenuItem.from_dict(connexion.request.get_json()) # noqa: E501
21+
return 'do some magic!'
22+
23+
24+
def list_menu(limit=None): # noqa: E501
25+
"""List all menu items
26+
27+
# noqa: E501
28+
29+
:param limit: How many items to return at one time (max 100)
30+
:type limit: int
31+
32+
:rtype: List[MenuItem]
33+
"""
34+
return 'do some magic!'
35+
36+
37+
def show_menu_item_by_id(item_id): # noqa: E501
38+
"""Info for a specific menu item
39+
40+
# noqa: E501
41+
42+
:param item_id: The id of the menu item to retrieve
43+
:type item_id: str
44+
45+
:rtype: MenuItem
46+
"""
47+
return 'do some magic!'

0 commit comments

Comments
 (0)