Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhereEclipseCon 2018 - Jérémie Bresson - 2018-10-23
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPI
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Swagger vs OpenAPI: it is the same!
Swagger OpenAPI
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Jérémie BressonJava developer
@j2r2b
jmini
Open-source contributor
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. All rights reserved
Switzerland I Germany I United Kingdom I Czech Republic I Bulgaria I US
Conversational Banking made real
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhere
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhere
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhere
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhere
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPIs are everywhere
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Content of an OpenAPI Specification
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Content of an OpenAPI Specification
JSONor
YAML
Info
Servers Security
Paths
Tags ExternalDocs
Components
OpenAPI v3
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Content of an OpenAPI Specification
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Editors for OpenAPI specifications
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Swagger Online Editor
http://editor.swagger.io/
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Eclipse IDE plugin: KaiZen-OpenAPI-Editor
https://github.com/RepreZen/KaiZen-OpenAPI-Editor
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Postman client
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Postman
https://www.getpostman.com/
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Postman: import OpenAPI (v2)
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Server-side
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Support for OpenAPI (Java Server)
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Adding OpenAPI to a JAX-RS project
Thorntail(a.k.a WildFly Swarm)https://thorntail.io/
https://openliberty.io/
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Adding OpenAPI to a JAX-RS project
• Add the additional maven dependency:<dependency> <groupId>io.thorntail</groupId> <artifactId>microprofile-openapi</artifactId> </dependency>
• Add OpenAPI annotations (next to the JAX-RS ones)
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Code first approach
ServerClient
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Code first approach
ServerClient
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Specification first approach
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Start with a Specification
ServerClient
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Code generator: OpenAPI-Generator
OpenAPI Specification
OpenAPI Generator
HTML documentation Client Code Server Stub
...
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPI-Generator
• Open Source (Apache 2.0 License)
• Hosted on GitHub: https://github.com/OpenAPITools/openapi-generator
• Java code & mustache templates
• Fork of Swagger-Codegen
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPI-Generator - Usage
Generate a java client for the example application
java -jar ./openapi-generator-cli-3.3.1.jar generate
-i ../OpenAPI-Spec/todoapp.yaml
-g java
-o out/
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
OpenAPI: an ecosystem
Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
A lot of tools are available for OpenAPI
• Editors• Tool to generate documentation• Breaking change detection• Integration with existing tools (Postman, …)• Code generation
(OpenAPI-Generator, AutoRest, Swagger-Codegen, … )
Copyright ©2018 unblu inc. All rights reserved Copyright ©2018 unblu inc. Creative Commons BY-SA 4.0
Evaluate the Sessions
-1 0 +1Sign in and vote at eclipsecon.org
Thank you for your attention
@j2r2b
jmini
Code Examples:https://github.com/jmini/ece2018-openapi