Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
OpenAPI and Java - Portland - 2019-12-10
sullis
December 10, 2019
Programming
0
170
OpenAPI and Java - Portland - 2019-12-10
Portland Java User Group
Portland Oregon
December 10, 2019
#openapi
#java
sullis
December 10, 2019
Tweet
Share
More Decks by sullis
See All by sullis
Code generation on the Java VM 2022-04-19
sullis
0
40
Mockito 2022-01-25
sullis
0
110
GitHub Actions 2021-12-16
sullis
0
17
Apache Struts and the Equifax data breach 2021-06-03
sullis
0
28
Guardrail State of the Union 2021-04-13
sullis
0
170
Guardrail: State of the Union 2021-03-18
sullis
0
86
Java on AWS 2020-12-15
sullis
0
180
Continuous Delivery with GitHub Actions - DeliveryConf 2020
sullis
0
510
Code generation on the Java VM 2019-12-05
sullis
0
330
Other Decks in Programming
See All in Programming
Rust、何もわからない...#6発表資料
ryu19
0
140
Glance App Widgetでウィジェットを作ろう / MoT TechTalk #15
mot_techtalk
0
130
23年のJavaトレンドは?Quarkusで理解するコンテナネイティブJava
tatsuya1bm
1
130
NGK2023S - OCaml最高! スマホ開発にも使えちゃう?!
haochenxie
0
120
WordPress(再)入門 - 基礎知識・環境編
oleindesign
1
140
AWSとCPUのムフフな関係
cmdemura
0
480
監視せなあかんし、五大紙だけにオオカミってな🐺🐺🐺🐺🐺
sadnessojisan
2
1.6k
Writing Greener Java Applications
hollycummins
0
360
ipa-medit: Memory search and patch tool for IPA without Jailbreaking/ipa-medit-bh2022-europe
tkmru
0
130
Amazon QuickSightのアップデート -re:Invent 2022の復習&2022年ハイライト-
shogo452
0
240
Spring BootとKubernetesで実現する今どきのDevOps入門
xblood
0
390
ちょうぜつ改め21世紀ふつうのソフトウェア設計
tanakahisateru
7
6.5k
Featured
See All Featured
Statistics for Hackers
jakevdp
785
210k
Build your cross-platform service in a week with App Engine
jlugia
221
17k
Fontdeck: Realign not Redesign
paulrobertlloyd
74
4.3k
A designer walks into a library…
pauljervisheath
199
16k
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
197
10k
Building Applications with DynamoDB
mza
85
5k
GitHub's CSS Performance
jonrohan
1020
430k
Why You Should Never Use an ORM
jnunemaker
PRO
49
7.9k
Designing the Hi-DPI Web
ddemaree
273
32k
GraphQLとの向き合い方2022年版
quramy
20
9.9k
Building a Scalable Design System with Sketch
lauravandoore
451
31k
Why Our Code Smells
bkeepers
PRO
326
55k
Transcript
OpenAPI and Java Sean Sullivan Portland Java User Group December
10, 2019
About me software engineer Portland Oregon Java Scala
Agenda OpenAPI Real world examples Java tools and libraries API
guidelines
OpenAPI
OpenAPI is a specification for describing API’s
API specifications
WSDL (SOAP) WADL (REST)
Swagger (REST) OpenAPI (REST)
https://en.wikipedia.org/wiki/OpenAPI_Specification
REST API’s
API Driven Development
“API first”
source: Adobe Tech Blog June 2017
Code first vs API schema first
JSON or YAML
Real world examples
Case Study: stripe.com OpenAPI
https://github.com/stripe/openapi
https://github.com/stripe/openapi
Case Study: squareup.com OpenAPI
https://github.com/square/connect-api-specification
Case Study: Kubernetes OpenAPI
https://github.com/kubernetes/kubernetes/tree/master/api/openapi-spec
https://github.com/kubernetes-client/java Kubernetes Java Client
https://github.com/kubernetes-client/java Kubernetes Java Client code generation
Case Study: Microsoft Azure OpenAPI
https://github.com/Azure/azure-rest-api-specs azure-rest-api-specs
Case Study: Amazon EventBridge OpenAPI
https://docs.aws.amazon.com/eventbridge Amazon EventBridge “EventBridge is a serverless event bus service
that makes it easy to connect your applications with data from a variety of sources”
https://docs.aws.amazon.com/eventbridge EventBridge Schema Registry Schemas are defined using JSON files,
using the OpenAPI specification
https://www.tbray.org/ongoing/When/201x/2019/12/02/Strongly-Typed-Events Strongly typed events
Java tools and libraries
Swagger libraries swagger-core swagger-parser swagger-codegen swagger-inflector
https://github.com/swagger-api/swagger-parser Swagger parser
pom.xml <dependency> <groupId>io.swagger.parser.v3</groupId> <artifactId>swagger-parser</artifactId> <version>2.0.16</version> </dependency> Swagger parser
https://github.com/swagger-api/swagger-parser import io.swagger.v3.parser.OpenAPIV3Parser; import io.swagger.v3.oas.models.OpenAPI; String url = “http://petstore.swagger.io/v3/openapi.json”; OpenAPI
openAPI = new OpenAPIV3Parser().read(url); Swagger parser
https://github.com/swagger-api/swagger-parser Swagger parser Pull Request #1271
ObjectMapperFactory.java return new JsonFactoryBuilder() .enable(StreamReadFeature.STRICT_DUPLICATE_DETECTION) .build(); Swagger parser Pull Request
#1271
Code generators Guardrail openapi-generator swagger-codegen AutoRest
Guardrail project
https://guardrail.dev/ Guardrail
https://github.com/twilio/guardrail Guardrail
https://github.com/twilio/guardrail Guardrail: Scala ScalaMeta
https://github.com/twilio/guardrail Guardrail: Java JavaParser
Guardrail example
guardrail-maven-plugin <plugin> <groupId>com.twilio</groupId> <artifactId>guardrail-maven-plugin_2.12</artifactId> <version>0.54.5</version> <executions> … </executions> </plugin>
guardrail-maven-plugin <configuration> <language>java</language> <kind>client</kind> <framework>dropwizard</framework> <specPath>${project.basedir}/src/main/openapi/petstore.json</specPath> <packageName>com.example.clients.petstore</packageName> </configuration> Java client
guardrail-maven-plugin
openapi-generator project
openapi-generator
openapi-generator
openapi-generator
REST API guidelines
https://github.com/microsoft/api-guidelines
https://www.infoq.com/news/2016/07/microsoft-rest-api/ July 2016
https://cloud.google.com/apis/design/
https://github.com/zalando/restful-api-guidelines
https://github.com/paypal/api-standards/blob/master/api-style-guide.md
Final thoughts use OpenAPI to define REST API’s adopt “API
First” approach use a code generator to generate client libraries contribute to open source projects
The End