Slide 1

Slide 1 text

Automating your API Client Library Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 2

Slide 2 text

What is automation ? Automation is the technology by which a process or procedure is performed without human assistance. — Wikipédia Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 3

Slide 3 text

Why did we do this ? — Our webservice API is pretty large — Our webservice API has changed a lot recently — It's fun to try new technologies and share them with you — We will most certainly never have to use AFNetworking or Alamofire again! Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 4

Slide 4 text

Goals — Always be up to date with the webservice API — Reduce work on repetitive tasks with low added value — Simplifying our codebase, improve consistency — Up to date documentation baked into the API client library Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 5

Slide 5 text

Step to edit our client library(before) Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 6

Slide 6 text

Step to edit our client library(before) Way too many steps ! Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 7

Slide 7 text

Step to edit our client library(a!er) Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 8

Slide 8 text

How did we did it ? — Generate an API Description file — Define how we want to have our code generated througt templates files — Use the API Description file to generate the API Client library Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 9

Slide 9 text

This is how we do it ! — Generate an API Description file — Define how we want to have our code generated througt templates files — Use the API Description file to generate the API Client library Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 10

Slide 10 text

What is an API Description file A file that is used to describe and document HTTP RESTful APIs like Swagger, OpenAPI, API Blueprint or RAML. Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 11

Slide 11 text

API Description file — Share API design process — Generate API documentation — Generate API validation / testing — Generate client code — Generate server code — Generate mock Server — Generate mock Client Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 12

Slide 12 text

We chose Swagger Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 13

Slide 13 text

Automation Script Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 14

Slide 14 text

Automation Script Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 15

Slide 15 text

SwagGen — Customise models and API Client with templating and options — Generate all models — Generate the API Client layer Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 16

Slide 16 text

paths: /pet: post: summary: "Add a new pet to the store" operationId: "addPet" consumes: - "application/json" - "application/xml" produces: - "application/xml" - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" required: true schema: $ref: "#/definitions/Pet" responses: 405: description: "Invalid input" Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 17

Slide 17 text

definitions: Pet: type: "object" required: - "name" properties: id: type: "integer" format: "int64" category: $ref: "#/definitions/Category" name: type: "string" example: "doggie" status: type: "string" description: "pet status in the store" enum: - "available" - "pending" - "sold" Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 18

Slide 18 text

Automated generation Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 19

Slide 19 text

Automated generation ./swaggen generate swagger.json Loading spec from swagger.json Loaded spec: "PagesJaunes" - 44 operations, 330 definitions Loaded template: 19 template files, 15 options Destination: /Users/jmacko/pj/Swagger/SwaggerService/Generated/Swift Generation complete: 390 created Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 20

Slide 20 text

Automated generation ./swaggen generate swagger.json Loading spec from swagger.json Loaded spec: "PagesJaunes" - 44 operations, 330 definitions Loaded template: 19 template files, 15 options Destination: /Users/jmacko/pj/Swagger/SwaggerService/Generated/Swift Generation complete: 390 created Only 6,42s Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 21

Slide 21 text

Automated generation ./swaggen generate swagger.json Loading spec from swagger.json Loaded spec: "PagesJaunes" - 44 operations, 330 definitions Loaded template: 19 template files, 15 options Destination: /Users/jmacko/pj/Swagger/SwaggerService/Generated/Swift Generation complete: 390 created Only 6,42s for generating an API Client library Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 22

Slide 22 text

Automated generation ./swaggen generate swagger.json Loading spec from swagger.json Loaded spec: "PagesJaunes" - 44 operations, 330 definitions Loaded template: 19 template files, 15 options Destination: /Users/jmacko/pj/Swagger/SwaggerService/Generated/Swift Generation complete: 390 created Only 6,42s for generating an API Client library - 330 models - API Client Layer (44 endpoints) Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 23

Slide 23 text

Automated generation ./swaggen generate swagger.json Loading spec from swagger.json Loaded spec: "PagesJaunes" - 44 operations, 330 definitions Loaded template: 19 template files, 15 options Destination: /Users/jmacko/pj/Swagger/SwaggerService/Generated/Swift Generation complete: 390 created Only 6,42s for generating an API Client library - 330 models - API Client Layer (44 endpoints) It can also work on Android or any other language Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 24

Slide 24 text

Human generation ( ! / " ) Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 25

Slide 25 text

Human generation ( ! / " ) Working on repetitive tasks with low added value Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 26

Slide 26 text

Human generation ( ! / " ) Working on repetitive tasks with low added value Only 2678400s Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 27

Slide 27 text

Human generation ( ! / " ) Working on repetitive tasks with low added value Only 2678400s of human work: - 330 models - API Client Layer (44 endpoints) - A few bugs - Less rigorous code - Less new features in the product Automating your API Client Library - FrenchKit 2018 - @jeffreymacko

Slide 28

Slide 28 text

Merci. Automating your API Client Library - FrenchKit 2018 - @jeffreymacko