Add YAML export from APISpec

This commit is contained in:
Richard 2021-06-27 21:08:48 +01:00
parent 5279becce7
commit 8157fa6d58
4 changed files with 29 additions and 0 deletions

View file

@ -4,3 +4,4 @@ from .captures import *
from .instrument import *
from .stage import *
from .streams import *
from .docs import *

View file

@ -0,0 +1,21 @@
from labthings.views import View
from labthings import current_labthing
from flask import Response
class APISpecJSONView(View):
"""OpenAPI v3 documentation
A JSON document containing an API description in OpenAPI format
"""
def get(self):
return current_labthing().spec.to_dict()
class APISpecYAMLView(View):
"""OpenAPI v3 documentation
A YAML document containing an API description in OpenAPI format
"""
def get(self):
return Response(current_labthing().spec.to_yaml(), mimetype='text/yaml')