SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
How to Generate a REST
CXF3 Application from a
Swagger-Contract
Johannes Fiala, Developer
Agenda
• Generate based on contract
• Extend using code first
• Freeze the contract
• Use the REST API
• Generate client code (Java/Javascript)
• Access with a browser using a UI
• View/Share as HTML/PDF
• Customize the code generator
Toolchain
• Apache CXF 3
• + SwaggerFeature
• + Spring configuration
• + Spring Boot integration (start/tests)
• Swagger-Tools
• Swagger-Editor
• Swagger-Codegen
• Swagger-UI
• Swagger2Markup
Contract first, then code, then contract
Complete process flow
About me…
• Spring REST / Swagger-Springfox
• Added BeanValidation support
• Swagger-Codegen
• Created Javascript client
• Add BeanValidation support for Java
• Improved CXF server (generate complete server)
• Created CXF client
• Swagger2Markup
• Added BeanValidation support
Contract
• WADL (XML-based)
• By w3c, Last update 2009
• Swagger (Json/Yaml-based)
• By Linux foundation
• Version 1.0 – 2011 (Wordnik)
• Version 1.2 - 2014
• Version 2.0 – 2015 / transferred to Linux foundation / Open-API
initiative
• Next version 3.0
• Others: Blueprint, RAML, …
Open API / Swagger
• A language-agnostic interface to REST APIs
• allows to discover and understand the capabilities of a service
• Supported Formats: JSON/YAML
https://github.com/OAI/OpenAPI-Specification
Contract editors
• Swagger Editor
• by SmartBear
• Eclipse SwagEdit
• By RepreZen API Studio
• Commercial Tools:
• Restlet Studio
• RepreZen API Studio
Swagger-Editor (Json)
Swagger-Editor
• By SmartBear
• Javascript application
• Run locally using npm
• Edit Json / Yaml format
• Generate server
• Generate client
• Import using URL / copy/paste
https://github.com/swagger-api/swagger-editor
Generate the server stub
Swagger-Codegen
• by SmartBear (Apache License)
• Version 2.2.0
• Java program
• Mustache templating
• Generates server + client code
• 32 Supported languages: Java, C#, Javascript, Dart, Groovy,
JaxRS, NodeJS, Objective-C, Perl, PHP, Python, Ruby, Scala,
…
https://github.com/swagger-api/swagger-codegen
Generate the server stub
Swagger-Codegen
• Supported server stubs for Java:
• Java JAX RS
• 2.0 spec
• Jersey
• CXF
• Resteasy
• Spring MVC
• Spring Boot
CXF server stub
Features
• Scheduled for version 2.2.2
• Generates Interface/Implementation/Models
• Generate a complete web application
• Context.xml / ApplicationContext.xml
• Web.xml
• Jboss: jboss-web.xml
• Spring Boot support
• Run as Spring-Boot Application
• Tests
• Run using Spring Integrationtests using random ports
• Currently no update/merge for new methods …
Swagger-Codegen CLI
• io.swagger.codegen.Codegen
-i hello_world.json
-l jaxrs-cxf
-o c:hello_world_project
-c hello_world_config.json
Swagger-Codegen CLI
Configuration file
Demo
• Create hello world service
• Generate CXF server stub (with Spring support enabled)
• Run using Spring Boot
• Run Junit-Tests
• Deploy to application server (Jboss EAP 7)
CXF server stub
Supported Features
• Spring application
• Swagger generator
• WADL generator
• BeanValidation annotations
• Activate automatic BeanValidation (1.1)
• Compression (gzip)
• Logging
• Integration-Tests (Spring Boot)
Swagger-Codegen CLI
Display all language options
• io.swagger.codegen.SwaggerCodegen
config-help -l jaxrs-cxf
or
• java -jar modules/swagger-codegen-cli/target/swagger-
codegen-cli.jar config-help –l jaxrs-cxf
Swagger-Codegen CLI
language options for cxf
Demo
• Re-Generate with more options
• BeanValidation
• Gzip
• Logging
Further development
life cycle
• Extend the API
• code first
• Use the API
• Frontend development
• Finalize: Freeze the contract
Further development life cycle
Contract
Generate
Code
Add/Modify
Code
Extend the application
• Modify your API:
• Add new services (use JAXRS-annotations)
• Use Swagger annotations
• Use BeanValidation annotations
• Generated Swagger spec gets updated automatically
Extend the application
Swagger annotations
• Service:
• @Api – activate Swagger for api
• Operations:
• @ApiOperation - description
• @ApiResponse – error codes + return types
• Model:
• @ApiModel - description
• @ApiModelProperty - description
Freeze your API: contract
• Use the updated contract
• Generate interfaces/models
• Prevent accidential changes of the API
• Integrate in build job (Maven / Gradle)
• Will generate to target/generated-sources/swagger by default
• Use .swagger-codegen-ignore file to protect files from updates
• Tests are always protected
• https://github.com/swagger-api/swagger-
codegen/tree/master/modules/swagger-codegen-maven-plugin
Freeze your API: contract
Demo
• Extend hello world service
(+ BeanValidation)
• Access updated specs
• Swagger spec
• WADL
• Freeze the contract
Spring Boot Hot-Deploy – Spring Loaded
• Allows hot deploy
• for adding new methods etc.
• Add JVM parameters:
• -javaagent:/path_to_spring-loaded/springloaded-1.2.5.RELEASE.jar –
noverify
• Used by Grails
• More Info: https://github.com/spring-projects/spring-loaded
Use your API
 Generate client stubs
• Swagger-Codegen
 Access your API using a browser
• Swagger-UI
 Generate HTML/PDF documentation
 Swagger2Markup
Swagger-Codegen
• Server + Client code stub generator
• Integration options
• Java application
• Maven
• Gradle
• https://github.com/swagger-api/swagger-codegen
Why generate client code?
• No more manual api calls
• Ensure consistency of your client code with the API!
• Makes code completion possible!
• Allows developers to read description for your operations and
models in the IDE
• You get compilation errors if the API breaks with newer
versions!
Swagger-UI
• By SmartBear
• Access your API with a browser
• Javascript application
• Can access the generated Swagger spec – always consistent
with your code
• Integration options:
• Copy into your webapp
• load as Web-Jar
https://github.com/swagger-api/swagger-ui
Swagger-UI
Swagger2Markup
• By Robert Winkler (github)
• Render your API in HTML/PDFs
• Uses Markdown/Asciidoctor files
• Completely customizable
• Integration options:
• Run as Program/Unittest
• Maven
https://github.com/Swagger2Markup/swagger2markup
Swagger2Markup
Swagger
contract
Asciidoctor Html
PDF
Demo
• Client stub generator:
• Java
• Javascript
• Swagger-UI
• Swagger2Markup
Migration – Ensure portability
• Keep method signatures clean
• Use JaxRS 2 Exceptions
• Use JaxRS Response only if necessary
• Keep framework-specific configuration separately
Customize the generator
• Generator implemented in Java (one class for each language)
• Mustache-files
• api.mustache
• apiServiceImpl.mustache
• pojo.mustache
• api_test.mustache
• …
• Jmustache:
• https://github.com/samskivert/jmustache
Customize the generator
• Use –t flag for your own templates
• Customize only the templates you need
• Examples:
• Add Maven profile for deployment
• Add logger declaration
• Customize generated unit tests
• …
Customize the generator
• Customize Codegen Languages
• Extend Language class
• Add it to io.swagger.codegen.CodegenConfig
• swagger-codegensrcmainresourcesMETA-
INFservicesio.swagger.codegen.CodegenConfig
• Copy language templates
• Also see "Building your own Templates"
• https://github.com/swagger-api/swagger-codegen/wiki/Building-your-own-
Templates
Demo
• Customize the generator
• E.g. custom pom.xml file for deployment
• Swagger-Codegen project structure
WADL  Swagger
• Use wadl2java to generate server stub
• BeanValidation: krasa-jaxb-tools
• Activate CXF3 SwaggerFeature
• Use generated Swagger-file
• Will include BeanValidation annotations for models
• You can use both WADL first + auto-generate Swagger contract
Wrapup
• Generate based on contract
• Swagger-Codegen server stubs
• Extend using code first
• CXF 3 Swagger Feature
• Freeze using contract
• Swagger-Codegen build integration (mvn/gradle/cmd)
• Use your application
• Generate client code (Swagger-Codegen)
• Use in browser (Swagger-UI)
• View/Share as HTML/PDF (Swagger2Markup)
• Customize the code generator
Contribute to the projects
• Swagger-Codegen
• Java / JMustache
• Swagger-UI
• Javascript
• Swagger-Editor
• Javascript
• Swagger2Markup
• Java/Asciidoctor
Links & Resources
• Swagger Editor
• http://editor.swagger.io/
• Swagger Codegen
• https://github.com/swagger-api/swagger-codegen
• Swagger UI
• https://github.com/swagger-api/swagger-ui
• CXF
• http://cxf.apache.org/
Thank you for your attention!
• Demo-Code:
http://github.com/jfiala/swagger-cxf-demo
• Contact:
• @johannes_fiala

Contenu connexe

Tendances

Writer APIs in Java faster with Swagger Inflector
Writer APIs in Java faster with Swagger InflectorWriter APIs in Java faster with Swagger Inflector
Writer APIs in Java faster with Swagger InflectorTony Tam
 
Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Tony Tam
 
Design Driven API Development
Design Driven API DevelopmentDesign Driven API Development
Design Driven API DevelopmentSokichi Fujita
 
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...johannes_fiala
 
Developing Faster with Swagger
Developing Faster with SwaggerDeveloping Faster with Swagger
Developing Faster with SwaggerTony Tam
 
Introducing swagger
Introducing swaggerIntroducing swagger
Introducing swaggerAmr Ali
 
Fastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + SwaggerFastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + SwaggerTony Tam
 
Writing REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger AdaWriting REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger AdaStephane Carrez
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grapevisnu priya
 
Simple REST-APIs with Dropwizard and Swagger
Simple REST-APIs with Dropwizard and SwaggerSimple REST-APIs with Dropwizard and Swagger
Simple REST-APIs with Dropwizard and SwaggerLeanIX GmbH
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0Kazuhiro Sera
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierMiroslav Resetar
 
Building RESTful APIs w/ Grape
Building RESTful APIs w/ GrapeBuilding RESTful APIs w/ Grape
Building RESTful APIs w/ GrapeDaniel Doubrovkine
 
Apache Big Data Europe 2015: Selected Talks
Apache Big Data Europe 2015: Selected TalksApache Big Data Europe 2015: Selected Talks
Apache Big Data Europe 2015: Selected TalksAndrii Gakhov
 
Level 3 REST Makes Your API Browsable
Level 3 REST Makes Your API BrowsableLevel 3 REST Makes Your API Browsable
Level 3 REST Makes Your API BrowsableMatt Bishop
 
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...Alvaro Sanchez-Mariscal
 
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...Alvaro Sanchez-Mariscal
 
Serverless 프레임워크로 Nuxt 앱 배포하기
Serverless 프레임워크로 Nuxt 앱 배포하기Serverless 프레임워크로 Nuxt 앱 배포하기
Serverless 프레임워크로 Nuxt 앱 배포하기Changwan Jun
 

Tendances (20)

Writer APIs in Java faster with Swagger Inflector
Writer APIs in Java faster with Swagger InflectorWriter APIs in Java faster with Swagger Inflector
Writer APIs in Java faster with Swagger Inflector
 
Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)
 
Swagger
SwaggerSwagger
Swagger
 
Design Driven API Development
Design Driven API DevelopmentDesign Driven API Development
Design Driven API Development
 
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...Enhance existing REST APIs  (e.g. Facebook Graph API) with code completion us...
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
 
Developing Faster with Swagger
Developing Faster with SwaggerDeveloping Faster with Swagger
Developing Faster with Swagger
 
Swagger UI
Swagger UISwagger UI
Swagger UI
 
Introducing swagger
Introducing swaggerIntroducing swagger
Introducing swagger
 
Fastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + SwaggerFastest to Mobile with Scalatra + Swagger
Fastest to Mobile with Scalatra + Swagger
 
Writing REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger AdaWriting REST APIs with OpenAPI and Swagger Ada
Writing REST APIs with OpenAPI and Swagger Ada
 
Building an API using Grape
Building an API using GrapeBuilding an API using Grape
Building an API using Grape
 
Simple REST-APIs with Dropwizard and Swagger
Simple REST-APIs with Dropwizard and SwaggerSimple REST-APIs with Dropwizard and Swagger
Simple REST-APIs with Dropwizard and Swagger
 
Skinny Framework 1.0.0
Skinny Framework 1.0.0Skinny Framework 1.0.0
Skinny Framework 1.0.0
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlier
 
Building RESTful APIs w/ Grape
Building RESTful APIs w/ GrapeBuilding RESTful APIs w/ Grape
Building RESTful APIs w/ Grape
 
Apache Big Data Europe 2015: Selected Talks
Apache Big Data Europe 2015: Selected TalksApache Big Data Europe 2015: Selected Talks
Apache Big Data Europe 2015: Selected Talks
 
Level 3 REST Makes Your API Browsable
Level 3 REST Makes Your API BrowsableLevel 3 REST Makes Your API Browsable
Level 3 REST Makes Your API Browsable
 
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
 
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
Creating applications with Grails, Angular JS and Spring Security - GR8Conf U...
 
Serverless 프레임워크로 Nuxt 앱 배포하기
Serverless 프레임워크로 Nuxt 앱 배포하기Serverless 프레임워크로 Nuxt 앱 배포하기
Serverless 프레임워크로 Nuxt 앱 배포하기
 

En vedette

Swagger in the API Lifecycle
Swagger in the API LifecycleSwagger in the API Lifecycle
Swagger in the API LifecycleOle Lensmar
 
A Tour of Swagger for APIs
A Tour of Swagger for APIsA Tour of Swagger for APIs
A Tour of Swagger for APIsAllen Dean
 
Understanding how to use Swagger and its tools
Understanding how to use Swagger and its toolsUnderstanding how to use Swagger and its tools
Understanding how to use Swagger and its toolsSwagger API
 
API Design first with Swagger
API Design first with SwaggerAPI Design first with Swagger
API Design first with SwaggerTony Tam
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsJohn Ferguson Smart Limited
 
Swaggerで始めるモデルファーストなAPI開発
Swaggerで始めるモデルファーストなAPI開発Swaggerで始めるモデルファーストなAPI開発
Swaggerで始めるモデルファーストなAPI開発Takuro Sasaki
 
Scale a Swagger based Web API (Guillaume Laforge)
Scale a Swagger based Web API (Guillaume Laforge)Scale a Swagger based Web API (Guillaume Laforge)
Scale a Swagger based Web API (Guillaume Laforge)Nordic APIs
 
Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0Pece Nikolovski
 
Crystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPICrystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPIScott Triglia
 

En vedette (11)

Templating with your {{mustache}}js
Templating with your {{mustache}}jsTemplating with your {{mustache}}js
Templating with your {{mustache}}js
 
Web pack and friends
Web pack and friendsWeb pack and friends
Web pack and friends
 
Swagger in the API Lifecycle
Swagger in the API LifecycleSwagger in the API Lifecycle
Swagger in the API Lifecycle
 
A Tour of Swagger for APIs
A Tour of Swagger for APIsA Tour of Swagger for APIs
A Tour of Swagger for APIs
 
Understanding how to use Swagger and its tools
Understanding how to use Swagger and its toolsUnderstanding how to use Swagger and its tools
Understanding how to use Swagger and its tools
 
API Design first with Swagger
API Design first with SwaggerAPI Design first with Swagger
API Design first with Swagger
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yards
 
Swaggerで始めるモデルファーストなAPI開発
Swaggerで始めるモデルファーストなAPI開発Swaggerで始めるモデルファーストなAPI開発
Swaggerで始めるモデルファーストなAPI開発
 
Scale a Swagger based Web API (Guillaume Laforge)
Scale a Swagger based Web API (Guillaume Laforge)Scale a Swagger based Web API (Guillaume Laforge)
Scale a Swagger based Web API (Guillaume Laforge)
 
Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0Consuming Restful APIs using Swagger v2.0
Consuming Restful APIs using Swagger v2.0
 
Crystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPICrystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPI
 

Similaire à How to generate a REST CXF3 application from Swagger ApacheConEU 2016

How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016johannes_fiala
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languageselliando dias
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASBuilding Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASKasun Gajasinghe
 
Application Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldApplication Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldAmazon Web Services
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?Ksenia Peguero
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with WebpackJake Peyser
 
AWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment ComplexityAWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment ComplexityAmazon Web Services
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache UsergridDavid M. Johnson
 
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...HostedbyConfluent
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyChanghwan Yi
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntAshley Roach
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2Jaliya Udagedara
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
A tale of two pizzas: Developer tools at AWS
A tale of two pizzas: Developer tools at AWSA tale of two pizzas: Developer tools at AWS
A tale of two pizzas: Developer tools at AWSAmazon Web Services
 

Similaire à How to generate a REST CXF3 application from Swagger ApacheConEU 2016 (20)

How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016How to generate a rest application - DevFest Vienna 2016
How to generate a rest application - DevFest Vienna 2016
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Java ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many LanguagesJava ScriptingJava Scripting: One VM, Many Languages
Java ScriptingJava Scripting: One VM, Many Languages
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASBuilding Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 AS
 
Application Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldApplication Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless World
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?
 
Bundle your modules with Webpack
Bundle your modules with WebpackBundle your modules with Webpack
Bundle your modules with Webpack
 
AWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment ComplexityAWS CodeDeploy: Manage Deployment Complexity
AWS CodeDeploy: Manage Deployment Complexity
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache Usergrid
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
Kafka for Microservices – You absolutely need Avro Schemas! | Gerardo Gutierr...
 
JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssembly
 
Building a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger HuntBuilding a REST API Microservice for the DevNet API Scavenger Hunt
Building a REST API Microservice for the DevNet API Scavenger Hunt
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2ASP.NET MVC 5 and SignalR 2
ASP.NET MVC 5 and SignalR 2
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
A tale of two pizzas: Developer tools at AWS
A tale of two pizzas: Developer tools at AWSA tale of two pizzas: Developer tools at AWS
A tale of two pizzas: Developer tools at AWS
 

Dernier

Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Onlineanilsa9823
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 

Dernier (20)

Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 

How to generate a REST CXF3 application from Swagger ApacheConEU 2016

  • 1. How to Generate a REST CXF3 Application from a Swagger-Contract Johannes Fiala, Developer
  • 2. Agenda • Generate based on contract • Extend using code first • Freeze the contract • Use the REST API • Generate client code (Java/Javascript) • Access with a browser using a UI • View/Share as HTML/PDF • Customize the code generator
  • 3. Toolchain • Apache CXF 3 • + SwaggerFeature • + Spring configuration • + Spring Boot integration (start/tests) • Swagger-Tools • Swagger-Editor • Swagger-Codegen • Swagger-UI • Swagger2Markup
  • 4. Contract first, then code, then contract
  • 6. About me… • Spring REST / Swagger-Springfox • Added BeanValidation support • Swagger-Codegen • Created Javascript client • Add BeanValidation support for Java • Improved CXF server (generate complete server) • Created CXF client • Swagger2Markup • Added BeanValidation support
  • 7. Contract • WADL (XML-based) • By w3c, Last update 2009 • Swagger (Json/Yaml-based) • By Linux foundation • Version 1.0 – 2011 (Wordnik) • Version 1.2 - 2014 • Version 2.0 – 2015 / transferred to Linux foundation / Open-API initiative • Next version 3.0 • Others: Blueprint, RAML, …
  • 8. Open API / Swagger • A language-agnostic interface to REST APIs • allows to discover and understand the capabilities of a service • Supported Formats: JSON/YAML https://github.com/OAI/OpenAPI-Specification
  • 9. Contract editors • Swagger Editor • by SmartBear • Eclipse SwagEdit • By RepreZen API Studio • Commercial Tools: • Restlet Studio • RepreZen API Studio
  • 11. Swagger-Editor • By SmartBear • Javascript application • Run locally using npm • Edit Json / Yaml format • Generate server • Generate client • Import using URL / copy/paste https://github.com/swagger-api/swagger-editor
  • 12. Generate the server stub Swagger-Codegen • by SmartBear (Apache License) • Version 2.2.0 • Java program • Mustache templating • Generates server + client code • 32 Supported languages: Java, C#, Javascript, Dart, Groovy, JaxRS, NodeJS, Objective-C, Perl, PHP, Python, Ruby, Scala, … https://github.com/swagger-api/swagger-codegen
  • 13. Generate the server stub Swagger-Codegen • Supported server stubs for Java: • Java JAX RS • 2.0 spec • Jersey • CXF • Resteasy • Spring MVC • Spring Boot
  • 14. CXF server stub Features • Scheduled for version 2.2.2 • Generates Interface/Implementation/Models • Generate a complete web application • Context.xml / ApplicationContext.xml • Web.xml • Jboss: jboss-web.xml • Spring Boot support • Run as Spring-Boot Application • Tests • Run using Spring Integrationtests using random ports • Currently no update/merge for new methods …
  • 15. Swagger-Codegen CLI • io.swagger.codegen.Codegen -i hello_world.json -l jaxrs-cxf -o c:hello_world_project -c hello_world_config.json
  • 17. Demo • Create hello world service • Generate CXF server stub (with Spring support enabled) • Run using Spring Boot • Run Junit-Tests • Deploy to application server (Jboss EAP 7)
  • 18. CXF server stub Supported Features • Spring application • Swagger generator • WADL generator • BeanValidation annotations • Activate automatic BeanValidation (1.1) • Compression (gzip) • Logging • Integration-Tests (Spring Boot)
  • 19. Swagger-Codegen CLI Display all language options • io.swagger.codegen.SwaggerCodegen config-help -l jaxrs-cxf or • java -jar modules/swagger-codegen-cli/target/swagger- codegen-cli.jar config-help –l jaxrs-cxf
  • 21. Demo • Re-Generate with more options • BeanValidation • Gzip • Logging
  • 22. Further development life cycle • Extend the API • code first • Use the API • Frontend development • Finalize: Freeze the contract
  • 23. Further development life cycle Contract Generate Code Add/Modify Code
  • 24. Extend the application • Modify your API: • Add new services (use JAXRS-annotations) • Use Swagger annotations • Use BeanValidation annotations • Generated Swagger spec gets updated automatically
  • 25. Extend the application Swagger annotations • Service: • @Api – activate Swagger for api • Operations: • @ApiOperation - description • @ApiResponse – error codes + return types • Model: • @ApiModel - description • @ApiModelProperty - description
  • 26. Freeze your API: contract • Use the updated contract • Generate interfaces/models • Prevent accidential changes of the API • Integrate in build job (Maven / Gradle) • Will generate to target/generated-sources/swagger by default • Use .swagger-codegen-ignore file to protect files from updates • Tests are always protected • https://github.com/swagger-api/swagger- codegen/tree/master/modules/swagger-codegen-maven-plugin
  • 27. Freeze your API: contract
  • 28. Demo • Extend hello world service (+ BeanValidation) • Access updated specs • Swagger spec • WADL • Freeze the contract
  • 29. Spring Boot Hot-Deploy – Spring Loaded • Allows hot deploy • for adding new methods etc. • Add JVM parameters: • -javaagent:/path_to_spring-loaded/springloaded-1.2.5.RELEASE.jar – noverify • Used by Grails • More Info: https://github.com/spring-projects/spring-loaded
  • 30. Use your API  Generate client stubs • Swagger-Codegen  Access your API using a browser • Swagger-UI  Generate HTML/PDF documentation  Swagger2Markup
  • 31. Swagger-Codegen • Server + Client code stub generator • Integration options • Java application • Maven • Gradle • https://github.com/swagger-api/swagger-codegen
  • 32. Why generate client code? • No more manual api calls • Ensure consistency of your client code with the API! • Makes code completion possible! • Allows developers to read description for your operations and models in the IDE • You get compilation errors if the API breaks with newer versions!
  • 33. Swagger-UI • By SmartBear • Access your API with a browser • Javascript application • Can access the generated Swagger spec – always consistent with your code • Integration options: • Copy into your webapp • load as Web-Jar https://github.com/swagger-api/swagger-ui
  • 35. Swagger2Markup • By Robert Winkler (github) • Render your API in HTML/PDFs • Uses Markdown/Asciidoctor files • Completely customizable • Integration options: • Run as Program/Unittest • Maven https://github.com/Swagger2Markup/swagger2markup
  • 37. Demo • Client stub generator: • Java • Javascript • Swagger-UI • Swagger2Markup
  • 38. Migration – Ensure portability • Keep method signatures clean • Use JaxRS 2 Exceptions • Use JaxRS Response only if necessary • Keep framework-specific configuration separately
  • 39. Customize the generator • Generator implemented in Java (one class for each language) • Mustache-files • api.mustache • apiServiceImpl.mustache • pojo.mustache • api_test.mustache • … • Jmustache: • https://github.com/samskivert/jmustache
  • 40. Customize the generator • Use –t flag for your own templates • Customize only the templates you need • Examples: • Add Maven profile for deployment • Add logger declaration • Customize generated unit tests • …
  • 41. Customize the generator • Customize Codegen Languages • Extend Language class • Add it to io.swagger.codegen.CodegenConfig • swagger-codegensrcmainresourcesMETA- INFservicesio.swagger.codegen.CodegenConfig • Copy language templates • Also see "Building your own Templates" • https://github.com/swagger-api/swagger-codegen/wiki/Building-your-own- Templates
  • 42. Demo • Customize the generator • E.g. custom pom.xml file for deployment • Swagger-Codegen project structure
  • 43. WADL  Swagger • Use wadl2java to generate server stub • BeanValidation: krasa-jaxb-tools • Activate CXF3 SwaggerFeature • Use generated Swagger-file • Will include BeanValidation annotations for models • You can use both WADL first + auto-generate Swagger contract
  • 44. Wrapup • Generate based on contract • Swagger-Codegen server stubs • Extend using code first • CXF 3 Swagger Feature • Freeze using contract • Swagger-Codegen build integration (mvn/gradle/cmd) • Use your application • Generate client code (Swagger-Codegen) • Use in browser (Swagger-UI) • View/Share as HTML/PDF (Swagger2Markup) • Customize the code generator
  • 45. Contribute to the projects • Swagger-Codegen • Java / JMustache • Swagger-UI • Javascript • Swagger-Editor • Javascript • Swagger2Markup • Java/Asciidoctor
  • 46. Links & Resources • Swagger Editor • http://editor.swagger.io/ • Swagger Codegen • https://github.com/swagger-api/swagger-codegen • Swagger UI • https://github.com/swagger-api/swagger-ui • CXF • http://cxf.apache.org/
  • 47. Thank you for your attention! • Demo-Code: http://github.com/jfiala/swagger-cxf-demo • Contact: • @johannes_fiala