Add YAML export from APISpec
This commit is contained in:
parent
5279becce7
commit
8157fa6d58
4 changed files with 29 additions and 0 deletions
|
|
@ -13,6 +13,11 @@ help:
|
|||
|
||||
.PHONY: help Makefile
|
||||
|
||||
openapi: $(BUILDDIR)/swagger.yaml
|
||||
|
||||
$(BUILDDIR)/swagger.yaml: Makefile
|
||||
curl http://localhost:5000/api/v2/docs/swagger.yaml > $@
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
|
|
|
|||
|
|
@ -153,6 +153,8 @@ labthing.add_view(
|
|||
views.NestedConfigurationProperty, "/instrument/configuration/<path:route>"
|
||||
)
|
||||
labthing.add_root_link(views.ConfigurationProperty, "instrumentConfiguration")
|
||||
labthing.add_view(views.APISpecJSONView, "/docs/swagger.json")
|
||||
labthing.add_view(views.APISpecYAMLView, "/docs/swagger.yaml")
|
||||
|
||||
# Attach stage resources
|
||||
labthing.add_view(views.StageTypeProperty, "/instrument/stage/type")
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ from .captures import *
|
|||
from .instrument import *
|
||||
from .stage import *
|
||||
from .streams import *
|
||||
from .docs import *
|
||||
21
openflexure_microscope/api/v2/views/docs.py
Normal file
21
openflexure_microscope/api/v2/views/docs.py
Normal 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')
|
||||
Loading…
Add table
Add a link
Reference in a new issue