building apis with node.js and swagger
TRANSCRIPT
Building APIs in Node.js with SwaggerJeremy Whitlock
What is an API?
An API is an “application programming interface”… the interface for interaction.
APIAPIs are Building Blocks
APIs in the Physical World
Input Contract
APIs Define an Interaction Model
Output Contract
APIs Define an Interaction Model
Without documentation…
… how can you expect developers to get in?
What is Swagger?
http://swagger.io
Swagger is a specification to describe APIs.
Swagger emerges as an industry standard
Swagger Documents
• Written in JSON or YAML• Clearly describe:
–Available APIs–API input contract–API output contract–Required authn/authz–Success/Error responses–…
•Extensible
It is much more than just Swagger-UI!
How Do People Use Swagger?
Swagger
Mixing Swagger with Code
Swagger
Mixing Swagger with Code
Duplication
Code Without Swagger
Swagger-Driven APIs
Swagger: Not just for documentation!
Swagger-Driven APIs
Swagger
Swagger Metadata
Routing
Security
Request Validation
Response Validation
Business Logic
There is no wrong approach. Use what makes sense for you.
Swagger tooling for Node.js (and more)
> npm install swagger-tools
swagger-editor (http://editor.swagger.io/)
> npm install swagger
Announcing: apistudio.io
Write your spec and docs render live
Shareable spec and mock server
But it doesn't end there…
Thank you