Add Swagger-based API

This commit is contained in:
Gergely Polonkai 2016-10-27 20:18:02 +02:00
parent 07872f8e24
commit 50ef1491f2
7 changed files with 46 additions and 23 deletions

23
.swagger-codegen-ignore Normal file
View File

@ -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

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Rubber Duck Booking Tool
Rubber Duck Booking Tool for the masses
This tool allows you to manage your rubber duck repository, helping
your fellow developers to get the proper duck
for [debugging](http://en.wikipedia.org/wiki/Rubber_duck_debugging).

23
api.py
View File

@ -1,23 +0,0 @@
# -*- coding: utf-8
from flask import Flask
from flask_restful import Resource, Api, reqparse
app = Flask(__name__)
api = Api(app)
parser = reqparse.RequestParser()
parser.add_argument('task')
class HelloWorld(Resource):
def get(self):
return {"hello": "world"}
def post(self):
print(parser.parse_args())
return {'hello': 'world'}
api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
app.run(debug=True)

11
app.py Normal file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python3
import connexion
if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml',
arguments={
'title': 'Rubber Duck Booking Tool'
})
app.run(port=8080)

0
controllers/__init__.py Normal file
View File

View File

@ -0,0 +1,3 @@
def ducks_get() -> str:
return 'do some magic!'

View File

@ -1,2 +1,4 @@
Flask==0.11.1
Flask-RESTful==0.3.5
connexion==1.0.129
gunicorn