1
0
mirror of https://github.com/enpaul/kodak.git synced 2024-11-14 18:46:50 +00:00
kodak/fresnel_lens/resources/openapi.py

26 lines
699 B
Python

from pathlib import Path
from ruamel.yaml import YAML
from fresnel_lens.resources._shared import FresnelResource
from fresnel_lens.resources._shared import ResponseTuple
yaml = YAML(typ="safe")
class OpenAPI(FresnelResource):
"""Handle requests for the OpenAPI specification resource"""
routes = ("/openapi.json",)
def get(self) -> ResponseTuple:
"""Retrieve the OpenAPI specification document"""
with (Path(__file__).parent / "openapi.yaml").open() as infile:
data = yaml.load(infile)
return self.make_response(data)
def head(self) -> ResponseTuple:
"""Alias of GET with no response body"""
return self._head(self.get())