POC: produce Swagger documentation for subiquity's API#2338
Draft
ogayot wants to merge 2 commits intocanonical:mainfrom
Draft
POC: produce Swagger documentation for subiquity's API#2338ogayot wants to merge 2 commits intocanonical:mainfrom
ogayot wants to merge 2 commits intocanonical:mainfrom
Conversation
Using python3-aiohttp-apispec, one can now document our API using @docs decorators in subiquity/common/apidef.py. The swagger.json file (legacy OpenAPI) can be downloaded at /swagger.json: $ curl --unix-socket socket http://a/swagger.json Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using python3-aiohttp-apispec, one can now document our API using
@docsdecorators insubiquity/common/apidef.py. I did a very simple example (without specifying the parameters and response schema).The
swagger.jsonfile can be downloaded at/swagger.json{ "paths": { "/ssh": { "get": { "responses": { "200": { "description": "OK" } }, "parameters": [], "summary": "Get SSH configuration", "description": "Return the current SSH configuration, including whether the SSH server is installed and enabled, and whether SSH keys are imported. ", "produces": [ "application/json" ] }, "post": { "responses": { "200": { "description": "OK" } }, "parameters": [], "summary": "Configure the SSH server", "description": "Configure if the SSH server is installed and enabled.\nOne can also pass SSH keys to be added as authorized keys for the user.", "produces": [ "application/json" ] } } }, "info": { "title": "Subiquity API documentation", "version": "v1" }, "swagger": "2.0" }It can then be fed to local tools or online tools such as https://editor.swagger.io/
Example on editor.swagger.io: