38

Automatically serve Swagger ui for Api Gateway documentation

 5 years ago
source link: https://www.tuicool.com/articles/hit/E7VN7nZ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

logo.png

When developing serverless function over the aws cloud platform, you also creating an open api definition (swagger documentation), in order to download the file easily from the command line you can use tools like aws-cli or npm package .

Checkout this post for more details.

OK! so now what ? we have the swagger file an ugly json or yml that don't really help us by them self, so now we need to use swagger ui, or swagger editor, to actually see and interact with our api documentations.

Again why not automate the process, so micro-swagger was born, and what we doing with micro-swagger is to connect this two steps into one elegant process, micro-swagger will download and serve the file locally for you to use and interact with.

npm i -g micro-swagger
micro-swagger start

This is basically it, the browser will pop up with the ui, fetching the api docs from AWS Api Gateway (first load is slow if you have many apis), in the list you can pick a stage, like prod, and the you will get a list of all the api in this stage, you can use the swagger ui by clicking the name to the editor by clicking the pencil icon.

home.PNG

apis.PNG

swagger-ui.PNG

swagger-editor.PNG


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK