30
Building APIs in Node.js with Swagger Jeremy Whitlock

Building APIs with Node.js and Swagger

Embed Size (px)

Citation preview

Page 1: Building APIs with Node.js and Swagger

Building APIs in Node.js with SwaggerJeremy Whitlock

Page 2: Building APIs with Node.js and Swagger

What is an API?

Page 3: Building APIs with Node.js and Swagger

An API is an “application programming interface”… the interface for interaction.

Page 4: Building APIs with Node.js and Swagger

APIAPIs are Building Blocks

Page 5: Building APIs with Node.js and Swagger

APIs in the Physical World

Page 6: Building APIs with Node.js and Swagger

Input Contract

APIs Define an Interaction Model

Page 7: Building APIs with Node.js and Swagger

Output Contract

APIs Define an Interaction Model

Page 8: Building APIs with Node.js and Swagger

Without documentation…

… how can you expect developers to get in?

Page 9: Building APIs with Node.js and Swagger

What is Swagger?

http://swagger.io

Page 10: Building APIs with Node.js and Swagger

Swagger is a specification to describe APIs.

Page 11: Building APIs with Node.js and Swagger

Swagger emerges as an industry standard

Page 12: Building APIs with Node.js and Swagger

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

It is much more than just Swagger-UI!

Page 14: Building APIs with Node.js and Swagger

How Do People Use Swagger?

Page 15: Building APIs with Node.js and Swagger

Swagger

Mixing Swagger with Code

Page 16: Building APIs with Node.js and Swagger

Swagger

Mixing Swagger with Code

Duplication

Page 17: Building APIs with Node.js and Swagger

Code Without Swagger

Page 18: Building APIs with Node.js and Swagger

Swagger-Driven APIs

Swagger: Not just for documentation!

Page 19: Building APIs with Node.js and Swagger

Swagger-Driven APIs

Swagger

Swagger Metadata

Routing

Security

Request Validation

Response Validation

Business Logic

Page 20: Building APIs with Node.js and Swagger

There is no wrong approach. Use what makes sense for you.

Page 21: Building APIs with Node.js and Swagger

Swagger tooling for Node.js (and more)

Page 22: Building APIs with Node.js and Swagger

> npm install swagger-tools

Page 23: Building APIs with Node.js and Swagger

swagger-editor (http://editor.swagger.io/)

Page 24: Building APIs with Node.js and Swagger

> npm install swagger

Page 25: Building APIs with Node.js and Swagger
Page 26: Building APIs with Node.js and Swagger

Announcing: apistudio.io

Page 27: Building APIs with Node.js and Swagger

Write your spec and docs render live

Page 28: Building APIs with Node.js and Swagger

Shareable spec and mock server

Page 29: Building APIs with Node.js and Swagger

But it doesn't end there…

Page 30: Building APIs with Node.js and Swagger

Thank you