diff --git a/royalnet/backpack/stars/api_docs.py b/royalnet/backpack/stars/api_docs.py index 128afb26..e306b234 100644 --- a/royalnet/backpack/stars/api_docs.py +++ b/royalnet/backpack/stars/api_docs.py @@ -6,5 +6,7 @@ from royalnet.version import semantic class ApiDocsStar(ApiStar): path = "/api/docs" + summary = "Get the swagger.json file used to generate this documentation." + async def api(self, data: ApiData) -> ru.JSON: return diff --git a/royalnet/backpack/stars/docs.py b/royalnet/backpack/stars/docs.py index 885d2616..97494f2d 100644 --- a/royalnet/backpack/stars/docs.py +++ b/royalnet/backpack/stars/docs.py @@ -11,14 +11,21 @@ class DocsStar(PageStar): path = "/docs" async def page(self, request: Request) -> Response: + paths = {} + + for star in self.constellation.stars: + if not isinstance(star, ApiStar): + continue + paths[star.path] = star.swagger() + spec = json.dumps({ "swagger": "2.0", "info": { "description": "Autogenerated Royalnet API documentation", "title": "Royalnet", "version": f"{semantic}", - "paths": [star.swagger() for star in self.constellation.stars if isinstance(star, ApiStar)] - } + }, + "paths": paths }) return HTMLResponse( @@ -26,17 +33,21 @@ class DocsStar(PageStar):