building apis with node.js and swagger
TRANSCRIPT
![Page 1: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/1.jpg)
Building APIs in Node.js with SwaggerJeremy Whitlock
![Page 2: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/2.jpg)
What is an API?
![Page 3: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/3.jpg)
An API is an “application programming interface”… the interface for interaction.
![Page 4: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/4.jpg)
APIAPIs are Building Blocks
![Page 5: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/5.jpg)
APIs in the Physical World
![Page 6: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/6.jpg)
Input Contract
APIs Define an Interaction Model
![Page 7: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/7.jpg)
Output Contract
APIs Define an Interaction Model
![Page 8: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/8.jpg)
Without documentation…
… how can you expect developers to get in?
![Page 9: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/9.jpg)
What is Swagger?
http://swagger.io
![Page 10: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/10.jpg)
Swagger is a specification to describe APIs.
![Page 11: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/11.jpg)
Swagger emerges as an industry standard
![Page 12: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/12.jpg)
Swagger Documents
• Written in JSON or YAML• Clearly describe:
–Available APIs–API input contract–API output contract–Required authn/authz–Success/Error responses–…
•Extensible
![Page 13: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/13.jpg)
It is much more than just Swagger-UI!
![Page 14: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/14.jpg)
How Do People Use Swagger?
![Page 15: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/15.jpg)
Swagger
Mixing Swagger with Code
![Page 16: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/16.jpg)
Swagger
Mixing Swagger with Code
Duplication
![Page 17: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/17.jpg)
Code Without Swagger
![Page 18: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/18.jpg)
Swagger-Driven APIs
Swagger: Not just for documentation!
![Page 19: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/19.jpg)
Swagger-Driven APIs
Swagger
Swagger Metadata
Routing
Security
Request Validation
Response Validation
Business Logic
![Page 20: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/20.jpg)
There is no wrong approach. Use what makes sense for you.
![Page 21: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/21.jpg)
Swagger tooling for Node.js (and more)
![Page 22: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/22.jpg)
> npm install swagger-tools
![Page 23: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/23.jpg)
swagger-editor (http://editor.swagger.io/)
![Page 24: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/24.jpg)
> npm install swagger
![Page 25: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/25.jpg)
![Page 26: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/26.jpg)
Announcing: apistudio.io
![Page 27: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/27.jpg)
Write your spec and docs render live
![Page 28: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/28.jpg)
Shareable spec and mock server
![Page 29: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/29.jpg)
But it doesn't end there…
![Page 30: Building APIs with Node.js and Swagger](https://reader036.vdocuments.site/reader036/viewer/2022062300/55c6d721bb61eb6c5a8b4754/html5/thumbnails/30.jpg)
Thank you