From 70fd7d041c9caf27748c7b01a83d5049f5b4d286 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 9 Mar 2020 16:00:22 +0100 Subject: [PATCH] Complete openapi 3 implementation --- royalnet/backpack/stars/api_login_royalnet.py | 2 ++ royalnet/backpack/stars/api_royalnet_version.py | 2 ++ royalnet/backpack/stars/api_token_create.py | 2 ++ royalnet/backpack/stars/api_token_info.py | 2 ++ royalnet/backpack/stars/api_token_passwd.py | 2 ++ royalnet/constellation/api/apistar.py | 3 +++ 6 files changed, 13 insertions(+) diff --git a/royalnet/backpack/stars/api_login_royalnet.py b/royalnet/backpack/stars/api_login_royalnet.py index be6fda94..23744346 100644 --- a/royalnet/backpack/stars/api_login_royalnet.py +++ b/royalnet/backpack/stars/api_login_royalnet.py @@ -18,6 +18,8 @@ class ApiLoginRoyalnetStar(ApiStar): "password": "The password of the user you are logging in as." } + tags = ["royalnet"] + async def api(self, data: ApiData) -> ru.JSON: TokenT = self.alchemy.get(Token) UserT = self.alchemy.get(User) diff --git a/royalnet/backpack/stars/api_royalnet_version.py b/royalnet/backpack/stars/api_royalnet_version.py index d5290097..c746cffe 100644 --- a/royalnet/backpack/stars/api_royalnet_version.py +++ b/royalnet/backpack/stars/api_royalnet_version.py @@ -8,6 +8,8 @@ class ApiRoyalnetVersionStar(ApiStar): summary = "Get the current Royalnet version." + tags = ["royalnet"] + async def api(self, data: ApiData) -> ru.JSON: return { "semantic": rv.semantic diff --git a/royalnet/backpack/stars/api_token_create.py b/royalnet/backpack/stars/api_token_create.py index 3af69016..cfae4133 100644 --- a/royalnet/backpack/stars/api_token_create.py +++ b/royalnet/backpack/stars/api_token_create.py @@ -16,6 +16,8 @@ class ApiTokenCreateStar(ApiStar): "duration": "The duration in seconds of the new token." } + tags = ["royalnet"] + async def api(self, data: ApiData) -> ru.JSON: user = await data.user() try: diff --git a/royalnet/backpack/stars/api_token_info.py b/royalnet/backpack/stars/api_token_info.py index 6b9be17f..606c6858 100644 --- a/royalnet/backpack/stars/api_token_info.py +++ b/royalnet/backpack/stars/api_token_info.py @@ -7,6 +7,8 @@ class ApiTokenInfoStar(ApiStar): summary = "Get info the current login token." + tags = ["royalnet"] + async def api(self, data: ApiData) -> ru.JSON: token = await data.token() return token.json() diff --git a/royalnet/backpack/stars/api_token_passwd.py b/royalnet/backpack/stars/api_token_passwd.py index 62dcf8e5..d26ffe8f 100644 --- a/royalnet/backpack/stars/api_token_passwd.py +++ b/royalnet/backpack/stars/api_token_passwd.py @@ -17,6 +17,8 @@ class ApiTokenPasswdStar(ApiStar): "new_password": "The password you want to set." } + tags = ["royalnet"] + async def api(self, data: ApiData) -> ru.JSON: TokenT = self.alchemy.get(Token) token = await data.token() diff --git a/royalnet/constellation/api/apistar.py b/royalnet/constellation/api/apistar.py index 67c7b9bb..62ccdd53 100644 --- a/royalnet/constellation/api/apistar.py +++ b/royalnet/constellation/api/apistar.py @@ -17,6 +17,8 @@ class ApiStar(PageStar, ABC): parameters: Dict[str, str] = {} + tags: List[str] = [] + async def page(self, request: Request) -> JSONResponse: if request.query_params: data = request.query_params @@ -64,6 +66,7 @@ class ApiStar(PageStar, ABC): "500": {"description": "Serverside unhandled exception"}, "501": {"description": "Not yet implemented"} }, + "tags": cls.tags, "parameters": [{ "name": parameter, "in": "query",