Streamlining API with Swagger.io

Preview:

Citation preview

STREAMLINING API WITH SWAGGER.IO

VICTOR AUGUSTEO

SHORT PROFILE

▸ Victor Augusteo

▸ Frontend engineer @ PwC Experience Centre

▸ Mostly iOS and web apps

▸ augusteo@gmail.com

▸ linkedin.com/in/victoraugusteo

QUICK OVERVIEW

▸ 2 parts talk

▸ intro to swagger

▸ live demo

▸ for front, back-end and test engineers

▸ how swagger would be useful for you

▸ be aware that it is an option

CONVENTIONAL API LIFECYCLE

BACKEND IMPLEMENTS API

BACKENDS TELLS FRONTEND THE

DETAILS

FRONTEND CONSUMES THE

API

OR THE OTHER WAY AROUND

FRONTEND TELLS BACKEND WHAT

API IT NEEDS

BACKEND IMPLEMENTS API

FRONTEND CONSUMES THE

API

USUALLY RESULTING IN

▸ lots of back and forth between frontend-backend

▸ non-standardized api style (usually)

▸ extra step to write documentation outside codebase

▸ multiple sources-of-truth

▸ need to test using REST clients like curl or Paw

WOULDN’T IT BE AWESOME FOR A TOOL TO SOLVE ALL OUR PROBLEMS?

ENTER SWAGGER.IO

SO WHAT IS IT?

▸ swagger

▸ codegen

▸ ui

▸ editor

▸ OpenAPI-Spec

SWAGGER

▸ the brain - generates and consume swagger file

▸ java, js, node authored by the swagger team

▸ and many community driven language integrations

CODEGEN

▸ stub code generator for server and client

UI

dependency-free html for api documentation and sandbox, serves as the contract between front/backend devs

EDITOR

live edit swagger file (JSON/YAML), codegen, example, etc.

OPENAPI SPECIFICATION

‣ a set of standards on how to write your api

‣ popular ~ 3000 ⭐on github, backed by Linux foundation

HOW DO YOU USE IT?

▸ start with swagger definitions, generate the server & client code then flesh out the implementations

▸ if you have existing project and you are using supported frameworks, then swagger definitions can be automatically generated for you given you write swagger comments in the API points

▸ Node, Java, JS, .Net, PHP, Python, Ruby, Scala, etc.

▸ full list @ http://swagger.io/open-source-integrations/

QUICK LIVE DEMO!

▸ run swagger-editor locally

▸ use swagger editor to create api spec

▸ hello world api & sum two numbers api

▸ generate server stub in Ruby Sinatra and run it on localhost

▸ consume the api with generated Swift client

1. RUN SWAGGER-EDITOR LOCALLY

SWAGGER HELPS US TO

▸ communicate more effectively

▸ standardized api across engineers

▸ easy to use generated documentation

▸ single source of truth

▸ built in REST client to test

RESOURCES LINKS

▸ http://swagger.io

▸ https://github.com/OAI/OpenAPI-Specification

▸ email me augusteo@gmail.com

▸ connect on linkedin.com/in/victoraugusteo

QUESTIONS ?I HAS BEEN AN HONOR!

Recommended