Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Swagger API generation for Flask-MongoRest

Project Description
flask-mongorest-swagger
=======================

Swagger API generation for Flask-MongoRest


Example
------
rest_api = MongoRest(app)
swagger = Swagger(rest_api)

class ApiResource(mongorest.Resource):
document = DocumentClass
parameters = {
'extra_parameter': Parameter('query', 'string',
'Does something else')}

@swagger.register(url='/api-endpoint')
class ApiView(ResourceView):
resource = ApiResource

@swagger.route(
'/api-function', methods=['POST'],
description='The description of this API view',
endpoints=[Endpoint(
Endpoint(
'/api-function/',
login_description,
operations=[Operation(
'POST', 'function', 'More description!',
response_class='Token',
parameters={
'data': Parameter(
'body', 'Input', 'Whatever you need to pass in',
required=True)},
error_responses={401: 'Invalid e-mail/password'})])],
models={
'Input': Model('Input', {
'input_string': Property('string', 'Input to the function')}),
'Token': Model('Token', {
'token': Property(
'string', 'The token which comes back')})})
def api_function():
return 'Thanks!'

This generates a Swagger API available at <http://localhost:5000/api-docs.json>.


Thanks to
---------
* Swagger <https://developers.helloreverb.com/swagger/>
* Flask <http://flask.pocoo.org/>
* Flask-MongoRest <https://github.com/elasticsales/flask-mongorest>
* Matchbox <http://matchbox.net/>
Release History

Release History

This version
History Node

0.1

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting