Files
notifications-api/tests/app/spec/test_rest.py
Chris Hill-Scott 7c3d25a87a 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.
2016-06-29 12:07:32 +01:00

19 lines
575 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import flex
import pytest
from flask import json
from tests import create_authorization_header
def test_spec_returns_valid_json(notify_api, sample_notification):
with notify_api.test_request_context():
with notify_api.test_client() as client:
auth_header = create_authorization_header(service_id=sample_notification.service_id)
response = client.get('/spec', headers=[auth_header])
# Check that its a valid Swagger schema
flex.load(
json.loads(response.get_data(as_text=True))
)