Skip to main content

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

Project details


Release history Release notifications | RSS feed

This version

0.1

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page