From 3bf8d0ca832046924d68e65ba54eb4e03df23521 Mon Sep 17 00:00:00 2001 From: Adam Gaudreau Date: Tue, 23 Nov 2021 13:54:08 -0500 Subject: [PATCH 1/2] Add plugin apidocs --- app/api/v2/handlers/plugins_api.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/api/v2/handlers/plugins_api.py b/app/api/v2/handlers/plugins_api.py index 90a056c26..67b29349a 100644 --- a/app/api/v2/handlers/plugins_api.py +++ b/app/api/v2/handlers/plugins_api.py @@ -18,14 +18,25 @@ def add_routes(self, app: web.Application): router.add_get('/plugins', self.get_plugins) router.add_get('/plugins/{name}', self.get_plugin_by_name) - @aiohttp_apispec.docs(tags=['plugins']) + @aiohttp_apispec.docs(tags=['plugins'], + summary='Retrieve all plugins', + description='Returns a list of all available plugins in the system, including directory, description, and active status.') @aiohttp_apispec.querystring_schema(BaseGetAllQuerySchema) @aiohttp_apispec.response_schema(PluginSchema(many=True, partial=True)) async def get_plugins(self, request: web.Request): plugins = await self.get_all_objects(request) return web.json_response(plugins) - @aiohttp_apispec.docs(tags=['plugins']) + @aiohttp_apispec.docs(tags=['plugins'], + summary='Retrieve plugin by name', + description='If plugin was found with a matching name, an object containing information about the plugin is returned.', + parameters=[{ + 'in': 'path', + 'name': 'name', + 'description': 'The name of the plugin', + 'schema': {'type': 'string'}, + 'required': 'true' + }]) @aiohttp_apispec.querystring_schema(BaseGetOneQuerySchema) @aiohttp_apispec.response_schema(PluginSchema(partial=True)) async def get_plugin_by_name(self, request: web.Request): From 476e04bf9f697db3ef35d07ddfa2783f51a61117 Mon Sep 17 00:00:00 2001 From: Adam Gaudreau Date: Mon, 29 Nov 2021 12:36:16 -0500 Subject: [PATCH 2/2] Add description to response schema --- app/api/v2/handlers/plugins_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/v2/handlers/plugins_api.py b/app/api/v2/handlers/plugins_api.py index 67b29349a..32ba1166f 100644 --- a/app/api/v2/handlers/plugins_api.py +++ b/app/api/v2/handlers/plugins_api.py @@ -22,7 +22,7 @@ def add_routes(self, app: web.Application): summary='Retrieve all plugins', description='Returns a list of all available plugins in the system, including directory, description, and active status.') @aiohttp_apispec.querystring_schema(BaseGetAllQuerySchema) - @aiohttp_apispec.response_schema(PluginSchema(many=True, partial=True)) + @aiohttp_apispec.response_schema(PluginSchema(many=True, partial=True), description='Returns a list of all available plugins in the system.') async def get_plugins(self, request: web.Request): plugins = await self.get_all_objects(request) return web.json_response(plugins) @@ -38,7 +38,7 @@ async def get_plugins(self, request: web.Request): 'required': 'true' }]) @aiohttp_apispec.querystring_schema(BaseGetOneQuerySchema) - @aiohttp_apispec.response_schema(PluginSchema(partial=True)) + @aiohttp_apispec.response_schema(PluginSchema(partial=True), description='Returns a plugin with the requested name, if it exists.') async def get_plugin_by_name(self, request: web.Request): plugin = await self.get_object(request) return web.json_response(plugin)