[Python-modules-commits] [python-flask-restful-swagger] 01/03: import python-flask-restful-swagger_0.19.orig.tar.gz

Adrian Alves alvesadrian-guest at moszumanska.debian.org
Sun Jul 3 02:58:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

alvesadrian-guest pushed a commit to branch master
in repository python-flask-restful-swagger.

commit 2de9462860b352b8cd741e3096822056607e8fc9
Author: Adrian Alves <aalves at gmail.com>
Date:   Sat Jul 2 23:56:16 2016 -0300

    import python-flask-restful-swagger_0.19.orig.tar.gz
---
 LICENSE                                            |   20 +
 MANIFEST                                           |    4 +
 Makefile                                           |    4 +
 PKG-INFO                                           |   10 -
 TODO                                               |   10 +
 debian/.git-dpm                                    |    8 -
 debian/changelog                                   |    5 -
 debian/compat                                      |    1 -
 debian/control                                     |   21 -
 debian/copyright                                   |   38 -
 debian/docs                                        |    2 -
 debian/rules                                       |    8 -
 debian/source/format                               |    1 -
 examples/basic.py                                  |  225 +
 examples/blueprints.py                             |  233 +
 examples/inheritance.py                            |   62 +
 flask_restful_swagger.egg-info/PKG-INFO            |   10 -
 flask_restful_swagger.egg-info/SOURCES.txt         |   38 -
 .../dependency_links.txt                           |    1 -
 flask_restful_swagger.egg-info/not-zip-safe        |    1 -
 flask_restful_swagger.egg-info/requires.txt        |    1 -
 flask_restful_swagger.egg-info/top_level.txt       |    1 -
 setup.cfg                                          |    5 -
 setup.py                                           |    2 +-
 static/css/hightlight.default.css                  |  135 +
 static/css/screen.css                              | 1782 +++++
 static/docs.html                                   |   80 +
 static/images/logo_small.png                       |  Bin 0 -> 770 bytes
 static/images/pet_store_api.png                    |  Bin 0 -> 824 bytes
 static/images/throbber.gif                         |  Bin 0 -> 9257 bytes
 static/images/wordnik_api.png                      |  Bin 0 -> 980 bytes
 static/js/all.js                                   | 8151 ++++++++++++++++++++
 static/js/backbone-min.js                          |   38 +
 static/js/handlebars-1.0.rc.1.js                   | 1920 +++++
 static/js/highlight.7.3.pack.js                    |    1 +
 static/js/jquery-1.8.0.min.js                      |    2 +
 static/js/jquery.ba-bbq.min.js                     |   18 +
 static/js/jquery.slideto.min.js                    |    1 +
 static/js/jquery.wiggle.min.js                     |    8 +
 static/js/shred.bundle.js                          | 2765 +++++++
 static/js/shred/content.js                         |  193 +
 static/js/swagger-ui.js                            | 2239 ++++++
 static/js/swagger.js                               | 1106 +++
 static/js/underscore-min.js                        |   32 +
 static/resources.json                              |   10 +
 45 files changed, 19040 insertions(+), 152 deletions(-)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fbefeff
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Ran Tavory
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..94cc94f
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,4 @@
+# file GENERATED by distutils, do NOT edit
+setup.py
+flask_restful_swagger/__init__.py
+flask_restful_swagger/swagger.py
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1839758
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+release:
+	git tag -a `python setup.py --version` -m "Releasing to https://pypi.python.org/pypi/flask-restful-swagger/"
+	git push --tags
+	python setup.py sdist upload
diff --git a/PKG-INFO b/PKG-INFO
deleted file mode 100644
index a14d868..0000000
--- a/PKG-INFO
+++ /dev/null
@@ -1,10 +0,0 @@
-Metadata-Version: 1.0
-Name: flask-restful-swagger
-Version: 0.19
-Summary: Extrarct swagger specs from your flast-restful project
-Home-page: https://github.com/rantav/flask-restful-swagger
-Author: Ran Tavory
-Author-email: UNKNOWN
-License: MIT
-Description: Please see documentation here: https://github.com/rantav/flask-restful-swagger
-Platform: UNKNOWN
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..c04ff62
--- /dev/null
+++ b/TODO
@@ -0,0 +1,10 @@
+Syntactic sugar and smartness around dataType. Support the following:
+ - 'Model'
+ - Model
+ - 'List[Model]'
+ - ['Model']
+ - [Model]
+
+Support for HTML pages
+
+Create a pip package and publish it
diff --git a/debian/.git-dpm b/debian/.git-dpm
deleted file mode 100644
index 51c0f50..0000000
--- a/debian/.git-dpm
+++ /dev/null
@@ -1,8 +0,0 @@
-# see git-dpm(1) from git-dpm package
-efc9a3a67fbf45b7d4e0234db760e939937f03ae
-efc9a3a67fbf45b7d4e0234db760e939937f03ae
-efc9a3a67fbf45b7d4e0234db760e939937f03ae
-efc9a3a67fbf45b7d4e0234db760e939937f03ae
-python-flask-restful-swagger_0.19.orig.tar.gz
-c725c30810bedb93c08d9a0ac93ceef184317ed4
-170150
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b17bb3c..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-python-flask-restful-swagger (0.19-2) trusty; urgency=low
-
-  * Initial release (Closes: #819647)
-
- -- Adrian Alves <adrian at gluu.org>  Wed, 20 May 2015 14:00:59 -0400
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index ec63514..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/debian/control b/debian/control
deleted file mode 100644
index a8ec472..0000000
--- a/debian/control
+++ /dev/null
@@ -1,21 +0,0 @@
-Source: python-flask-restful-swagger
-Section: python
-Priority: optional
-Maintainer: Adrian Alves <adrian at gluu.org>
-Build-Depends: debhelper (>= 9.0.0),
- python,
- python-setuptools
-Standards-Version: 3.9.5
-Homepage: https://github.com/rantav/flask-restful-swagger
-X-Python-Version: >= 2.7
-
-Package: python-flask-restful-swagger
-Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}
-Description: Swagger spec extractor for flask-restful
- flask-restful-swagger is a wrapper for flask-restful 
- which enables swagger support. In essense, you just need
- to wrap the Api instance and add a few python decorators
- to get full swagger support.
-
-
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index bafd14c..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,38 +0,0 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: python-flask-restful-swagger
-Source: <url://example.com>
-
-Files: *
-Copyright: <years> <put author's name and email here>
-           <years> <likewise for another author>
-License: <special license>
- <Put the license of the package here indented by 1 space>
- <This follows the format of Description: lines in control file>
- .
- <Including paragraphs>
-
-# If you want to use GPL v2 or later for the /debian/* files use 
-# the following clauses, or change it to suit. Delete these two lines
-Files: debian/*
-Copyright: 2015 Adrian Alves <adrian at gluu.org>
-License: GPL-2+
- This package is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- .
- This package is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
- .
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>
- .
- On Debian systems, the complete text of the GNU General
- Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
-
-# Please also look if there are files or directories which have a
-# different copyright/license attached and list them here.
-# Please avoid to pick license terms that are more restrictive than the
-# packaged work, as it may make Debian's contributions unacceptable upstream.
diff --git a/debian/docs b/debian/docs
deleted file mode 100644
index 5a01470..0000000
--- a/debian/docs
+++ /dev/null
@@ -1,2 +0,0 @@
-README
-README.md
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index de1bd88..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-%:
-	dh $@ --with python2
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/examples/basic.py b/examples/basic.py
new file mode 100644
index 0000000..a52a8a8
--- /dev/null
+++ b/examples/basic.py
@@ -0,0 +1,225 @@
+'''
+Running:
+
+  PYTHONPATH=. python examples/basic.py
+
+'''
+
+
+from flask import Flask, redirect
+from flask.ext.restful import reqparse, abort, Api, Resource, fields,\
+    marshal_with
+from flask_restful_swagger import swagger
+
+app = Flask(__name__, static_folder='../static')
+
+###################################
+# This is important:
+api = swagger.docs(Api(app), apiVersion='0.1',
+                   basePath='http://localhost:5000',
+                   resourcePath='/',
+                   produces=["application/json", "text/html"],
+                   api_spec_url='/api/spec',
+                   description='A Basic API')
+###################################
+
+TODOS = {
+    'todo1': {'task': 'build an API'},
+    'todo2': {'task': '?????'},
+    'todo3': {'task': 'profit!'},
+}
+
+
+def abort_if_todo_doesnt_exist(todo_id):
+  if todo_id not in TODOS:
+    abort(404, message="Todo {} doesn't exist".format(todo_id))
+
+parser = reqparse.RequestParser()
+parser.add_argument('task', type=str)
+
+
+ at swagger.model
+class TodoItem:
+  """This is an example of a model class that has parameters in its constructor
+  and the fields in the swagger spec are derived from the parameters
+  to __init__.
+  In this case we would have args, arg2 as required parameters and arg3 as
+  optional parameter."""
+  def __init__(self, arg1, arg2, arg3='123'):
+    pass
+
+class Todo(Resource):
+  "My TODO API"
+  @swagger.operation(
+      notes='get a todo item by ID',
+      nickname='get',
+      # Parameters can be automatically extracted from URLs (e.g. <string:id>)
+      # but you could also override them here, or add other parameters.
+      parameters=[
+          {
+            "name": "todo_id_x",
+            "description": "The ID of the TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": 'string',
+            "paramType": "path"
+          },
+          {
+            "name": "a_bool",
+            "description": "The ID of the TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": 'boolean',
+            "paramType": "path"
+          }
+      ])
+  def get(self, todo_id):
+    # This goes into the summary
+    """Get a todo task
+
+    This will be added to the <strong>Implementation Notes</strong>.
+    It lets you put very long text in your api.
+
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
+    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
+    commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
+    velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
+    cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
+    est laborum.
+    """
+    abort_if_todo_doesnt_exist(todo_id)
+    return TODOS[todo_id], 200, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='delete a todo item by ID',
+  )
+  def delete(self, todo_id):
+    abort_if_todo_doesnt_exist(todo_id)
+    del TODOS[todo_id]
+    return '', 204, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='edit a todo item by ID',
+  )
+  def put(self, todo_id):
+    args = parser.parse_args()
+    task = {'task': args['task']}
+    TODOS[todo_id] = task
+    return task, 201, {'Access-Control-Allow-Origin': '*'}
+
+  def options (self, **args):
+    # since this method is not decorated with @swagger.operation it does not
+    # get added to the swagger docs
+    return {'Allow' : 'GET,PUT,POST,DELETE' }, 200, \
+    { 'Access-Control-Allow-Origin': '*', \
+      'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE', \
+      'Access-Control-Allow-Headers': 'Content-Type' }
+
+# TodoList
+#   shows a list of all todos, and lets you POST to add new tasks
+class TodoList(Resource):
+
+  def get(self):
+    return TODOS, 200, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='Creates a new TODO item',
+      responseClass=TodoItem.__name__,
+      nickname='create',
+      parameters=[
+          {
+            "name": "body",
+            "description": "A TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": TodoItem.__name__,
+            "paramType": "body"
+          }
+      ],
+      responseMessages=[
+          {
+              "code": 201,
+              "message": "Created. The URL of the created blueprint should " +
+              "be in the Location header"
+          },
+          {
+              "code": 405,
+              "message": "Invalid input"
+          }
+      ])
+  def post(self):
+    args = parser.parse_args()
+    todo_id = 'todo%d' % (len(TODOS) + 1)
+    TODOS[todo_id] = {'task': args['task']}
+    return TODOS[todo_id], 201, {'Access-Control-Allow-Origin': '*'}
+
+ at swagger.model
+class ModelWithResourceFields:
+  resource_fields = {
+      'a_string': fields.String()
+  }
+
+ at swagger.model
+ at swagger.nested(
+   a_nested_attribute=ModelWithResourceFields.__name__,
+   a_list_of_nested_types=ModelWithResourceFields.__name__)
+class TodoItemWithResourceFields:
+  """This is an example of how Output Fields work
+  (http://flask-restful.readthedocs.org/en/latest/fields.html).
+  Output Fields lets you add resource_fields to your model in which you specify
+  the output of the model when it gets sent as an HTTP response.
+  flask-restful-swagger takes advantage of this to specify the fields in
+  the model"""
+  resource_fields = {
+      'a_string': fields.String(attribute='a_string_field_name'),
+      'a_formatted_string': fields.FormattedString,
+      'an_enum': fields.String,
+      'an_int': fields.Integer,
+      'a_bool': fields.Boolean,
+      'a_url': fields.Url,
+      'a_float': fields.Float,
+      'an_float_with_arbitrary_precision': fields.Arbitrary,
+      'a_fixed_point_decimal': fields.Fixed,
+      'a_datetime': fields.DateTime,
+      'a_list_of_strings': fields.List(fields.String),
+      'a_nested_attribute': fields.Nested(ModelWithResourceFields.resource_fields),
+      'a_list_of_nested_types': fields.List(fields.Nested(ModelWithResourceFields.resource_fields)),
+  }
+
+  # Specify which of the resource fields are required
+  required = ['a_string']
+
+  swagger_metadata = {
+      'an_enum': {
+          'enum': ['one', 'two', 'three']
+      }
+  }
+
+class MarshalWithExample(Resource):
+  @swagger.operation(
+      notes='get something',
+      responseClass=TodoItemWithResourceFields,
+      nickname='get')
+  @marshal_with(TodoItemWithResourceFields.resource_fields)
+  def get(self, **kwargs):
+    return {}, 200,  {'Access-Control-Allow-Origin': '*'}
+
+
+##
+## Actually setup the Api resource routing here
+##
+api.add_resource(TodoList, '/todos')
+api.add_resource(Todo, '/todos/<string:todo_id>')
+api.add_resource(MarshalWithExample, '/marshal_with')
+
+
+ at app.route('/docs')
+def docs():
+  return redirect('/static/docs.html')
+
+
+if __name__ == '__main__':
+  TodoItemWithResourceFields()
+  TodoItem(1, 2, '3')
+  app.run(debug=True)
diff --git a/examples/blueprints.py b/examples/blueprints.py
new file mode 100644
index 0000000..fc8d154
--- /dev/null
+++ b/examples/blueprints.py
@@ -0,0 +1,233 @@
+'''
+Running:
+
+  PYTHONPATH=. python examples/basic.py
+
+  Goto: http://127.0.0.1:5000/api2/api/spec.html
+
+'''
+
+
+from flask import Flask, redirect, Blueprint
+from flask.ext.restful import reqparse, abort, Api, Resource, fields,\
+    marshal_with
+from flask_restful_swagger import swagger
+
+app = Flask(__name__, static_folder='../static')
+my_blueprint1 = Blueprint('my_blueprint1', __name__)
+my_blueprint2 = Blueprint('my_blueprint2', __name__)
+
+###################################
+# This is important:
+api1 = swagger.docs(Api(my_blueprint1), apiVersion='0.1',
+                   basePath='http://localhost:5000',
+                   resourcePath='/',
+                   produces=["application/json", "text/html"],
+                   api_spec_url='/api/spec',
+                   description='Blueprint1 Description')
+api2 = swagger.docs(Api(my_blueprint2), apiVersion='0.1',
+                   basePath='http://localhost:5000',
+                   resourcePath='/',
+                   produces=["application/json", "text/html"],
+                   api_spec_url='/api/spec',
+                   description='Blueprint2 Description')
+###################################
+
+TODOS = {
+    'todo1': {'task': 'build an API'},
+    'todo2': {'task': '?????'},
+    'todo3': {'task': 'profit!'},
+}
+
+
+def abort_if_todo_doesnt_exist(todo_id):
+  if todo_id not in TODOS:
+    abort(404, message="Todo {} doesn't exist".format(todo_id))
+
+parser = reqparse.RequestParser()
+parser.add_argument('task', type=str)
+
+
+ at swagger.model
+class TodoItem:
+  """This is an example of a model class that has parameters in its constructor
+  and the fields in the swagger spec are derived from the parameters
+  to __init__.
+  In this case we would have args, arg2 as required parameters and arg3 as
+  optional parameter."""
+  def __init__(self, arg1, arg2, arg3='123'):
+    pass
+
+class Todo(Resource):
+  "My TODO API"
+  @swagger.operation(
+      notes='get a todo item by ID',
+      nickname='get',
+      # Parameters can be automatically extracted from URLs (e.g. <string:id>)
+      # but you could also override them here, or add other parameters.
+      parameters=[
+          {
+            "name": "todo_id_x",
+            "description": "The ID of the TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": 'string',
+            "paramType": "path"
+          },
+          {
+            "name": "a_bool",
+            "description": "The ID of the TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": 'boolean',
+            "paramType": "path"
+          }
+      ])
+  def get(self, todo_id):
+    # This goes into the summary
+    """Get a todo task
+
+    This will be added to the <strong>Implementation Notes</strong>.
+    It let's you put very long text in your api.
+
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
+    veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
+    commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
+    velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
+    cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
+    est laborum.
+    """
+    abort_if_todo_doesnt_exist(todo_id)
+    return TODOS[todo_id], 200, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='delete a todo item by ID',
+  )
+  def delete(self, todo_id):
+    abort_if_todo_doesnt_exist(todo_id)
+    del TODOS[todo_id]
+    return '', 204, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='edit a todo item by ID',
+  )
+  def put(self, todo_id):
+    args = parser.parse_args()
+    task = {'task': args['task']}
+    TODOS[todo_id] = task
+    return task, 201, {'Access-Control-Allow-Origin': '*'}
+
+  def options (self, **args):
+    # since this method is not decorated with @swagger.operation it does not
+    # get added to the swagger docs
+    return {'Allow' : 'GET,PUT,POST,DELETE' }, 200, \
+    { 'Access-Control-Allow-Origin': '*', \
+      'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE', \
+      'Access-Control-Allow-Headers': 'Content-Type' }
+
+# TodoList
+#   shows a list of all todos, and lets you POST to add new tasks
+class TodoList(Resource):
+
+  def get(self):
+    return TODOS, 200, {'Access-Control-Allow-Origin': '*'}
+
+  @swagger.operation(
+      notes='Creates a new TODO item',
+      responseClass=TodoItem.__name__,
+      nickname='create',
+      parameters=[
+          {
+            "name": "body",
+            "description": "A TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": TodoItem.__name__,
+            "paramType": "body"
+          }
+      ],
+      responseMessages=[
+          {
+              "code": 201,
+              "message": "Created. The URL of the created blueprint should " +
+              "be in the Location header"
+          },
+          {
+              "code": 405,
+              "message": "Invalid input"
+          }
+      ])
+  def post(self):
+    args = parser.parse_args()
+    todo_id = 'todo%d' % (len(TODOS) + 1)
+    TODOS[todo_id] = {'task': args['task']}
+    return TODOS[todo_id], 201, {'Access-Control-Allow-Origin': '*'}
+
+ at swagger.model
+class ModelWithResourceFields:
+  resource_fields = {
+      'a_string': fields.String()
+  }
+
+ at swagger.model
+ at swagger.nested(
+   a_nested_attribute=ModelWithResourceFields.__name__,
+   a_list_of_nested_types=ModelWithResourceFields.__name__)
+class TodoItemWithResourceFields:
+  """This is an example of how Output Fields work
+  (http://flask-restful.readthedocs.org/en/latest/fields.html).
+  Output Fields lets you add resource_fields to your model in which you specify
+  the output of the model when it gets sent as an HTTP response.
+  flask-restful-swagger takes advantage of this to specify the fields in
+  the model"""
+  resource_fields = {
+      'a_string': fields.String(attribute='a_string_field_name'),
+      'a_formatted_string': fields.FormattedString,
+      'an_int': fields.Integer,
+      'a_bool': fields.Boolean,
+      'a_url': fields.Url,
+      'a_float': fields.Float,
+      'an_float_with_arbitrary_precision': fields.Arbitrary,
+      'a_fixed_point_decimal': fields.Fixed,
+      'a_datetime': fields.DateTime,
+      'a_list_of_strings': fields.List(fields.String),
+      'a_nested_attribute': fields.Nested(ModelWithResourceFields.resource_fields),
+      'a_list_of_nested_types': fields.List(fields.Nested(ModelWithResourceFields.resource_fields)),
+  }
+
+  # Specify which of the resource fields are required
+  required = ['a_string']
+
+class MarshalWithExample(Resource):
+  @swagger.operation(
+      notes='get something',
+      responseClass=TodoItemWithResourceFields,
+      nickname='get')
+  @marshal_with(TodoItemWithResourceFields.resource_fields)
+  def get(self, **kwargs):
+    return {}, 200,  {'Access-Control-Allow-Origin': '*'}
+
+
+##
+## Actually setup the Api resource routing here
+##
+api1.add_resource(TodoList, '/todos1')
+api1.add_resource(Todo, '/todos1/<string:todo_id>')
+api1.add_resource(MarshalWithExample, '/marshal_with1')
+api2.add_resource(TodoList, '/todos2')
+api2.add_resource(Todo, '/todos2/<string:todo_id>')
+api2.add_resource(MarshalWithExample, '/marshal_with2')
+
+
+ at app.route('/docs')
+def docs():
+  return redirect('/static/docs.html')
+
+
+if __name__ == '__main__':
+  TodoItemWithResourceFields()
+  TodoItem(1, 2, '3')
+  app.register_blueprint(my_blueprint1, url_prefix='/api1')
+  app.register_blueprint(my_blueprint2, url_prefix='/api2')
+  app.run(debug=True)
diff --git a/examples/inheritance.py b/examples/inheritance.py
new file mode 100644
index 0000000..e7787b3
--- /dev/null
+++ b/examples/inheritance.py
@@ -0,0 +1,62 @@
+'''
+Running:
+
+  PYTHONPATH=. python examples/inheritance.py
+
+'''
+from flask import Flask
+from flask.ext.restful import Api, Resource
+from flask_restful_swagger import swagger
+
+app = Flask(__name__, static_folder='../static')
+
+###################################
+# This is important:
+api = swagger.docs(Api(app), apiVersion='0.1',
+                   basePath='http://localhost:5000',
+                   resourcePath='/',
+                   produces=["application/json", "text/html"],
+                   api_spec_url='/api/spec',
+                   description='Inheritance demonstration')
+###################################
+
+
+class Base(Resource):
+  def get(self):
+    pass
+
+  def post(self):
+    pass
+
+  def delete(self):
+    pass
+
+
+class Inherited(Base):
+  @swagger.operation(
+      notes='just testing inheritance',
+      nickname='get',
+      parameters=[
+          {
+            "name": "a_bool",
+            "description": "The ID of the TODO item",
+            "required": True,
+            "allowMultiple": False,
+            "dataType": 'boolean',
+            "paramType": "path"
+          }
+      ])
+  def get(self):
+    return "hello"
+
+  def post(self):
+    # wont be visible in the swagger docs
+    return "world"
+
+##
+## Actually setup the Api resource routing here
+##
+api.add_resource(Inherited, '/inherited')
+
+if __name__ == '__main__':
+  app.run(debug=True)
diff --git a/flask_restful_swagger.egg-info/PKG-INFO b/flask_restful_swagger.egg-info/PKG-INFO
deleted file mode 100644
index a14d868..0000000
--- a/flask_restful_swagger.egg-info/PKG-INFO
+++ /dev/null
@@ -1,10 +0,0 @@
-Metadata-Version: 1.0
-Name: flask-restful-swagger
-Version: 0.19
-Summary: Extrarct swagger specs from your flast-restful project
-Home-page: https://github.com/rantav/flask-restful-swagger
-Author: Ran Tavory
-Author-email: UNKNOWN
-License: MIT
-Description: Please see documentation here: https://github.com/rantav/flask-restful-swagger
-Platform: UNKNOWN
diff --git a/flask_restful_swagger.egg-info/SOURCES.txt b/flask_restful_swagger.egg-info/SOURCES.txt
deleted file mode 100644
index 5fbb9d5..0000000
--- a/flask_restful_swagger.egg-info/SOURCES.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-MANIFEST.in
-README
-README.md
-setup.py
-flask_restful_swagger/__init__.py
-flask_restful_swagger/swagger.py
-flask_restful_swagger.egg-info/PKG-INFO
-flask_restful_swagger.egg-info/SOURCES.txt
-flask_restful_swagger.egg-info/dependency_links.txt
-flask_restful_swagger.egg-info/not-zip-safe
-flask_restful_swagger.egg-info/requires.txt
-flask_restful_swagger.egg-info/top_level.txt
-flask_restful_swagger/static/.gitignore
-flask_restful_swagger/static/endpoint.html
-flask_restful_swagger/static/index.html
-flask_restful_swagger/static/o2c.html
-flask_restful_swagger/static/swagger-ui.js
-flask_restful_swagger/static/swagger-ui.min.js
-flask_restful_swagger/static/css/highlight.default.css
-flask_restful_swagger/static/css/hightlight.default.css
-flask_restful_swagger/static/css/screen.css
-flask_restful_swagger/static/images/explorer_icons.png
-flask_restful_swagger/static/images/logo_small.png
-flask_restful_swagger/static/images/pet_store_api.png
-flask_restful_swagger/static/images/throbber.gif
-flask_restful_swagger/static/images/wordnik_api.png
-flask_restful_swagger/static/lib/backbone-min.js
-flask_restful_swagger/static/lib/handlebars-1.0.0.js
-flask_restful_swagger/static/lib/highlight.7.3.pack.js
-flask_restful_swagger/static/lib/jquery-1.8.0.min.js
-flask_restful_swagger/static/lib/jquery.ba-bbq.min.js
-flask_restful_swagger/static/lib/jquery.slideto.min.js
-flask_restful_swagger/static/lib/jquery.wiggle.min.js
-flask_restful_swagger/static/lib/shred.bundle.js
-flask_restful_swagger/static/lib/swagger-oauth.js
-flask_restful_swagger/static/lib/swagger.js
-flask_restful_swagger/static/lib/underscore-min.js
-flask_restful_swagger/static/lib/shred/content.js
\ No newline at end of file
diff --git a/flask_restful_swagger.egg-info/dependency_links.txt b/flask_restful_swagger.egg-info/dependency_links.txt
deleted file mode 100644
index 8b13789..0000000
--- a/flask_restful_swagger.egg-info/dependency_links.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/flask_restful_swagger.egg-info/not-zip-safe b/flask_restful_swagger.egg-info/not-zip-safe
deleted file mode 100644
index 8b13789..0000000
--- a/flask_restful_swagger.egg-info/not-zip-safe
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/flask_restful_swagger.egg-info/requires.txt b/flask_restful_swagger.egg-info/requires.txt
deleted file mode 100644
index 2cff2f2..0000000
--- a/flask_restful_swagger.egg-info/requires.txt
+++ /dev/null
@@ -1 +0,0 @@
-Flask-RESTful>=0.2.12
\ No newline at end of file
diff --git a/flask_restful_swagger.egg-info/top_level.txt b/flask_restful_swagger.egg-info/top_level.txt
deleted file mode 100644
index cbcf9ff..0000000
--- a/flask_restful_swagger.egg-info/top_level.txt
+++ /dev/null
@@ -1 +0,0 @@
-flask_restful_swagger
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 861a9f5..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-[egg_info]
-tag_build = 
-tag_date = 0
-tag_svn_revision = 0
-
diff --git a/setup.py b/setup.py
index 1ddf0a9..fdd4367 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README') as file:
     long_description = file.read()
 
 setup(name='flask-restful-swagger',
-      version='0.19',
+      version='0.18',
       url='https://github.com/rantav/flask-restful-swagger',
       zip_safe=False,
       packages=['flask_restful_swagger'],
diff --git a/static/css/hightlight.default.css b/static/css/hightlight.default.css
new file mode 100644
index 0000000..e417fc1
--- /dev/null
+++ b/static/css/hightlight.default.css
@@ -0,0 +1,135 @@
+/*
+
+Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac at SoftwareManiacs.Org>
+
+*/
+
+pre code {
+  display: block; padding: 0.5em;
+  background: #F0F0F0;
+}
+
+pre code,
+pre .subst,
+pre .tag .title,
+pre .lisp .title,
+pre .clojure .built_in,
+pre .nginx .title {
+  color: black;
+}
+
+pre .string,
+pre .title,
+pre .constant,
+pre .parent,
+pre .tag .value,
+pre .rules .value,
+pre .rules .value .number,
+pre .preprocessor,
+pre .ruby .symbol,
+pre .ruby .symbol .string,
+pre .aggregate,
+pre .template_tag,
+pre .django .variable,
+pre .smalltalk .class,
+pre .addition,
+pre .flow,
+pre .stream,
+pre .bash .variable,
+pre .apache .tag,
+pre .apache .cbracket,
+pre .tex .command,
+pre .tex .special,
+pre .erlang_repl .function_or_atom,
+pre .markdown .header {
+  color: #800;
+}
+
+pre .comment,
+pre .annotation,
+pre .template_comment,
+pre .diff .header,
+pre .chunk,
+pre .markdown .blockquote {
+  color: #888;
+}
+
+pre .number,
+pre .date,
+pre .regexp,
+pre .literal,
+pre .smalltalk .symbol,
+pre .smalltalk .char,
+pre .go .constant,
+pre .change,
+pre .markdown .bullet,
+pre .markdown .link_url {
+  color: #080;
+}
+
+pre .label,
+pre .javadoc,
+pre .ruby .string,
+pre .decorator,
+pre .filter .argument,
+pre .localvars,
+pre .array,
+pre .attr_selector,
+pre .important,
+pre .pseudo,
... 18521 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-flask-restful-swagger.git



More information about the Python-modules-commits mailing list