Example #1
0
    'Todo',
    {'task': fields.String(required=True, description='The task details')})

listed_todo = api.model(
    'ListedTodo', {
        'id': fields.String(required=True, description='The todo ID'),
        'todo': fields.Nested(todo, description='The Todo')
    })


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',
                    location='form')


@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(description='todo_id should be in {0}'.format(', '.join(
        TODOS.keys())))
    @api.marshal_with(todo)
    def get(self, todo_id):
Example #2
0
 def test_api_shortcut(self, app):
     api = Api(app)
     parser = api.parser()
     assert isinstance(parser, RequestParser)