Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Stop writing your API clients by hand
Search
Alan Cooke
August 22, 2018
Programming
1
120
Stop writing your API clients by hand
Introduction and demo of how one can use the Open API Spec to generate API clients on demand.
Alan Cooke
August 22, 2018
Tweet
Share
More Decks by Alan Cooke
See All by Alan Cooke
Robots, the best testers your will ever ever build
a1cooke
0
45
ROBOTS, THE BEST TESTERS YOU WILL EVER BUILD
a1cooke
0
130
Tales of a rebuild
a1cooke
0
21
Modernizing Objective-C using Swift
a1cooke
0
83
GDG August 2015 - Retrofit + GSON
a1cooke
0
59
Other Decks in Programming
See All in Programming
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
830
Apache Hive 4 on Treasure Data
ryukobayashi
0
380
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
190
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
190
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
390
雑に思考を整理する技術と効能
konifar
61
30k
見た目から始める生産性向上
ikumatadokoro
8
1k
Code Reviews
bkuhlmann
4
890
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
7
1.1k
Ruby Function Composition
bkuhlmann
1
330
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
280
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
27
8.4k
Featured
See All Featured
Docker and Python
trallard
35
2.7k
Infographics Made Easy
chrislema
238
18k
Building Your Own Lightsaber
phodgson
100
5.7k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Atom: Resistance is Futile
akmur
260
25k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Practical Orchestrator
shlominoach
183
9.7k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
Optimizing for Happiness
mojombo
370
69k
Clear Off the Table
cherdarchuk
85
310k
Side Projects
sachag
451
41k
Mobile First: as difficult as doing things right
swwweet
217
8.6k
Transcript
Stop writing your API clients by hand
None
Alan Cooke — Senior Staff Engineer, Mobile
None
None
None
Open API aka Swagger — Open standard — Machine readable
— Language agnostic approach to API specification
None
Path specification paths: /v2/track: post: operationId: Track summary: Track tags:
- Event consumes: - application/json parameters: - name: body in: body schema: $ref: '#/definitions/Event' responses: '200': description: '' security: - X-Outbound-Key: []
Model specification definitions: User: title: User type: object properties: user_id:
type: string first_name: type: string last_name: type: string email: type: string required: - user_id
Security schemes securityDefinitions: X-Outbound-Key: name: X-Outbound-Key type: apiKey in: header
Tooling — Open source tools — Node service you run
locally or hosting service, allows you edit and mock APIs — Commercial tooling — Stoplight.io
Code generators — Open Source repo: https://github.com/swagger-api/ swagger-codegen/ Project broken
into two parts 1. Command Line Interface - swagger-codegen-cli 1. Code generator - swagger-codegen
Writing your own generator 1. Java class, allows you todo
any special pre/post processing of models 2. Collection of mustache template files used to translate model into code
public struct {{classname}}: Codable { {{#allVars}} {{#description}}/** {{description}} */ {{/description}}public
var {{name}}: {{{datatype}}} {{^required}}?{{/required}} {{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}} {{/allVars}} }
None
Demo
Questions
None