Skip to main content
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/>

Metadata

Release history Release notifications | RSS feed

This release

0.1 This release

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page