Metadata-Version: 1.1
Name: flask-restplus
Version: 0.2.3
Summary: Helpers, syntaxic sugar and Swagger documentation for Flask-Restful
Home-page: https://github.com/noirbizarre/flask-restplus
Author: Axel Haustant
Author-email: axel@data.gouv.fr
License: MIT
Download-URL: http://pypi.python.org/pypi/flask-restplus
Description: ==============
        Flask RestPlus
        ==============
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        Flask-RestPlus provide syntaxic suger, helpers and automatically generated `Swagger`_ documentation on top of `Flask-Restful`_.
        
        Compatibility
        =============
        
        Flask-RestPlus requires Python 2.7+.
        
        
        Installation
        ============
        
        You can install Flask-Restplus with pip:
        
        ::
        
            $ pip install flask-restplus
        
        or with easy_install:
        
        ::
        
            $ easy_install flask-restplus
        
        
        Quick start
        ===========
        
        With Flask-Restplus, you only import the api instance to route and document your endpoints.
        
        ::
        
            from flask import Flask
            from flask.ext.restplus import Api, Resource, fields
        
            app = Flask(__name__)
            api = Api(app, version='1.0', title='Todo API',
                description='A simple TODO API extracted from the original flask-restful example'
            )
        
            ns = api.namespace('todos', description='TODO operations')
        
            TODOS = {
                'todo1': {'task': 'build an API'},
                'todo2': {'task': '?????'},
                'todo3': {'task': 'profit!'},
            }
        
            todo_fields = api.model('Todo', {
                'task': fields.String(required=True, description='The task details')
            })
        
        
            def abort_if_todo_doesnt_exist(todo_id):
                if todo_id not in TODOS:
                    api.abort(404, "Todo {} doesn't exist".format(todo_id))
        
            parser = api.parser()
            parser.add_argument('task', type=str, required=True, help='The task details')
        
        
            @ns.route('/<string:todo_id>')
            @api.doc(responses={404: 'Todo not found'}, params={'todo_id': 'The Todo ID'})
            class Todo(Resource):
                '''Show a single todo item and lets you delete them'''
                @api.doc(notes='todo_id should be in {0}'.format(', '.join(TODOS.keys())))
                @api.marshal_with(todo_fields)
                def get(self, todo_id):
                    '''Fetch a given resource'''
                    abort_if_todo_doesnt_exist(todo_id)
                    return TODOS[todo_id]
        
                def delete(self, todo_id):
                    '''Delete a given resource'''
                    abort_if_todo_doesnt_exist(todo_id)
                    del TODOS[todo_id]
                    return '', 204
        
                @api.doc(parser=parser)
                @api.marshal_with(todo_fields)
                def put(self, todo_id):
                    '''Update a given resource'''
                    args = parser.parse_args()
                    task = {'task': args['task']}
                    TODOS[todo_id] = task
                    return task, 201
        
        
            @ns.route('/')
            class TodoList(Resource):
                '''Shows a list of all todos, and lets you POST to add new tasks'''
                @api.marshal_with(todo_fields, as_list=True)
                def get(self):
                    '''List all todos'''
                    return TODOS
        
                @api.doc(parser=parser)
                @api.marshal_with(todo_fields)
                def post(self):
                    '''Ceate a todo'''
                    args = parser.parse_args()
                    todo_id = 'todo%d' % (len(TODOS) + 1)
                    TODOS[todo_id] = {'task': args['task']}
                    return TODOS[todo_id], 201
        
        
            if __name__ == '__main__':
                app.run(debug=True)
        
        
        Documentation
        =============
        
        The documentation is hosted `on Read the Docs <http://flask-restplus.readthedocs.org/en/0.2.3/>`_
        
        
        .. _Swagger: http://swagger.wordnik.com/
        .. _Flask-Restful: http://flask-restful.readthedocs.org/en/latest/
        
        Changelog
        =========
        
        0.2.3
        -----
        
        - Fix custom fields registeration
        
        0.2.2
        -----
        
        - Fix model list in declaration
        
        0.2.1
        -----
        
        - Allow to type custom fields with ``Api.model``
        - Handle custom fields into ``fieds.List``
        
        0.2
        ---
        
        - Upgraded to SwaggerUI 0.2.22
        - Support additional field documentation attributes: ``required``, ``description``, ``enum``, ``min``, ``max`` and ``default``
        - Initial support for model in RequestParser
        
        0.1.3
        -----
        
        - Fix ``Api.marshal()`` shortcut
        
        0.1.2
        -----
        
        - Added ``Api.marshal_with()`` and ``Api.marshal_list_with()`` decorators
        - Added ``Api.marshal()`` shortcut
        
        
        0.1.1
        -----
        
        - Use ``zip_safe=False`` for proper packaging.
        
        
        0.1
        ---
        
        - Initial release
        
        
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Environment :: Web Environment
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Software Distribution
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
