Publish a Swagger specification

Adds a new endpoint (`/spec`) which returns a the specification of the
API in Swagger-formatted JSON.

This means we will have something to point frontends at, so we can
evaluate which ones we like.

Right now it’s all hand-defined. If we were consistent about our use of
Marshmallow we could generated the spec from the Marshmallow schemas.
This commit is contained in:
Chris Hill-Scott
2016-06-22 13:48:59 +01:00
parent 340abae82c
commit 7c3d25a87a
6 changed files with 352 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ def create_app(app_name=None):
from app.template_statistics.rest import template_statistics as template_statistics_blueprint
from app.events.rest import events as events_blueprint
from app.provider_details.rest import provider_details as provider_details_blueprint
from app.spec.rest import spec as spec_blueprint
application.register_blueprint(service_blueprint, url_prefix='/service')
application.register_blueprint(user_blueprint, url_prefix='/user')
@@ -83,6 +84,7 @@ def create_app(app_name=None):
application.register_blueprint(template_statistics_blueprint)
application.register_blueprint(events_blueprint)
application.register_blueprint(provider_details_blueprint, url_prefix='/provider-details')
application.register_blueprint(spec_blueprint, url_prefix='/spec')
return application
@@ -95,7 +97,8 @@ def init_app(app):
url_for('notifications.process_ses_response'),
url_for('notifications.process_firetext_response'),
url_for('notifications.process_mmg_response'),
url_for('status.show_delivery_status')
url_for('status.show_delivery_status'),
url_for('spec.get_spec')
]
if request.path not in no_auth_req:
from app.authentication import auth