Top Banner
Design Driven APIs with Node.js and Swagger Jeremy Whitlock (@whitlockjc) Software Engineer 1
30

I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Feb 15, 2017

Download

Software

Apigee
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Design Driven APIs with Node.js and SwaggerJeremy Whitlock (@whitlockjc)Software Engineer

1

Page 2: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

What is an API?

2

Page 3: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

3

Need vectors of these elements

Need correct heart

Page 4: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

API Documentation

4

Page 5: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

5

Need vectors of these elements

Need correct heart

Page 6: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

API Documentation is “Critical”

"While APIs are meant for computers, applications, and other systems, integrations all begin with helping other humans understand the what, and how of what an API does, making API docs a critical point in the API journey."

6©2015 Apigee. All Rights Reserved.

Page 7: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

7

Need vectors of these elements

Need correct heart

Page 8: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

If It Isn't Documented, It Doesn't Exist

“No matter how wonderful your library is and how intelligent its design, if you're the only one who understands it, it doesn't do any good. Documentation means not just autogenerated API references, but also annotated examples and in-depth tutorials. You need all three to make sure your library can be easily adopted.”

8©2015 Apigee. All Rights Reserved.

Nicholas Zakas

http://blog.codinghorror.com/if-it-isnt-documented-it-doesnt-exist/

Page 9: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

9

Need vectors of these elements

Need correct heart

Page 10: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Good API Documentation

10©2015 Apigee. All Rights Reserved.

Page 11: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Good API Documentation

11

API Documentation should be easy to understand.

Page 12: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

12

Need vectors of these elements

Need correct heart

WHY ALL THE API DOCUMENTATION TALK?

Page 13: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger

13

Page 14: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Sample Swagger Document

14©2015 Apigee. All Rights Reserved.

• Written in JSON or YAML• Clearly describe:

• Available APIs• API input contract• API output contract• Required authn/authz• Success/Error responses• …

• Extensible

Page 15: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger Emerging as an Industry Standard

15©2015 Apigee. All Rights Reserved.

Page 16: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

There is More to Swagger Than This!

16©2015 Apigee. All Rights Reserved.

Page 17: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

How Do I Use Swagger?

17

Page 18: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Code Driven Swagger

18©2015 Apigee. All Rights Reserved.

Swagger

Duplication

Page 19: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Code Driven Swagger

19©2015 Apigee. All Rights Reserved.

Swagger

Page 20: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger Driven Code

20©2015 Apigee. All Rights Reserved.

Page 21: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Emphasis slide

21

Before (43 lines) After (14 lines)

Page 22: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

22

Need vectors of these elements

Need correct heart

WHICH APPROACH IS BETTER?

Page 23: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger Driven APIs

23

Page 24: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

API Design

24

http://apistudio.io

Page 25: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

API Design

25

http://apistudio.io

Page 26: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

API Design

26

http://apistudio.io

Page 27: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

27

Need vectors of these elements

Need correct heart

Page 28: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger Driven Node.js APIs

28

npm install -g swagger

Page 29: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Swagger Driven Node.js APIs

29

npm install -g swagger

Swagger

Swagger Metadata

Routing

Security

Request Validation

Response Validation

Business Logic

Page 30: I Love APIs 2015: Create Design-driven APIs with Node.js and Swagger

Thank You

30