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
OpenAPI and Java - Portland - 2019-12-10
Search
sullis
December 10, 2019
Programming
0
210
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
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
130
Amazon S3 - Portland Java User Group 2024-09-17
sullis
0
67
Netty - Montreal Java User Group 2024-05-21
sullis
0
150
Netty Chicago Java User Group 2024-04-17
sullis
0
980
Java 21 - Portland Java User Group 2023-10-24
sullis
0
300
Microbenchmarking with JMH - Portland 2023-03-14
sullis
0
130
Code generation on the Java VM 2022-04-19
sullis
0
120
Mockito 2022-01-25
sullis
0
170
GitHub Actions 2021-12-16
sullis
0
38
Other Decks in Programming
See All in Programming
[Fin-JAWS 第38回 ~re:Invent 2024 金融re:Cap~]FaultInjectionServiceアップデート@pre:Invent2024
shintaro_fukatsu
0
340
rails newと同時に型を書く
aki19035vc
6
740
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
230
Amazon Nova Reelの可能性
hideg
0
250
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
4.2k
Terraform で作る Amazon ECS の CI/CD パイプライン
hiyanger
0
110
Alba: Why, How and What's So Interesting
okuramasafumi
0
240
SpringBoot3.4の構造化ログ #kanjava
irof
2
770
個人アプリを2年ぶりにアプデしたから褒めて / I just updated my personal app, praise me!
lovee
0
300
チームの立て直し施策をGoogleの 『効果的なチーム』と見比べてみた
maroon8021
0
270
オニオンアーキテクチャを使って、 Unityと.NETでコードを共有する
soi013
0
380
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
500
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Faster Mobile Websites
deanohume
305
30k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Thoughts on Productivity
jonyablonski
68
4.4k
Fireside Chat
paigeccino
34
3.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Mobile First: as difficult as doing things right
swwweet
222
9.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Typedesign – Prime Four
hannesfritz
40
2.5k
RailsConf 2023
tenderlove
29
980
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Being A Developer After 40
akosma
89
590k
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