SlideShare a Scribd company logo
(HOW TO) USE SWAGGER TO
DEVELOP REST APPLICATIONS
@johannes_fiala - JCON 2017
About me…
 Swagger-CodegenContributor
 Javascript, Jaxrs-CXF, BeanValidation for Java*,
Jaxrs-Resteasy
 Other contributions
 Spring REST / Swagger-Springfox
 BeanValidation support
 Swagger2Markup
 BeanValidation support
Agenda
 Generate based on contract
 Extend using code first
 Freeze the contract
 Use the RESTAPI
 Generate client code (Java/Javascript)
 Access with a browser using a UI
 View/Share as HTML/PDF
 Customize the code generator
Toolchain
 ApacheCXF 3
 + SwaggerFeature
 + Spring integration/Spring Boot integration
 Swagger-Tools
 Swagger-Editor / Eclipse KaiZen Plugin
 Swagger-Codegen
 Swagger-UI
 Swagger2Markup
Contract first, then code,
then contract …
Complete Process flow
Contract spec. formats
 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
 Version: 3.0 (released 2017-07)
 Others: Blueprint, RAML, …
Open API / Swagger
 A language-agnostic interface to RESTAPIs
 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
 Neu: KaiZen – für OpenAPI 2 + 3
 Templates nur fürYaml, nicht für Json
 CommercialTools:
 Restlet Studio
 RepreZenAPI Studio
Swagger-Editor (Json)
Eclipse + KaiZen Plugin
 Open Source
 https://github.com/RepreZen/KaiZen-OpenAPI-Editor
 Swagger 2 + 3
 Supports onlyYAML format
 Navigation
 Outline
 + Navigate using Ctrl+Click
 Templates
 Scope-specific
 Completely Customizable!
Eclipse + KaiZen Plugin
Eclipse + KaiZen Plugin
Templates
Eclipse + KaiZen Plugin
 Demo
Swagger-Codegen
 by SmartBear (Apache License)
 Version 2.2.3
 Java program
 + Mustache templating
 Generates server + client code
 Currently supports OpenAPI v2 !
 Support for 3.0 in progress…, see #6517
https://github.com/swagger-api/swagger-codegen
Swagger-Codegen
Supported Languages
 Client and/or Server available for:
 Android,Asp.net, AsyncScala, Bash, Clojure,ConfluenceWiki,
C++, C#, Dart, Elixir, Erlang, Finch, Flash, FlaskConnexion, Go,
Groovy, Haskell, Java,CXF, JavaInflector, Jaxrs-Spec, Jersey,
JavaMSF4J, Resteasy, Javascript,AngularJS, Jmeter, Lumen,
NancyFX, NodeJS, ObjC, Perl, Php, Python,Qt5C++, Rails,
Ruby, Scala, Scalatra, Silex, Sinatra, Slim (PHP), Spring, Static
Html, Swagger,Yaml, Swift,Tizen,TypescriptAngular,
Undertow, …
 And many more libraries (e.g. Java Jersey1, ok-http-gson, …)
Jcon 2017 How to use Swagger to develop REST applications
Generate the server stub
Swagger-Codegen
 Supported server stubs for Java:
 Java JAX RS
 2.0 spec
 Jersey
 CXF (Spring/CDI)
 Resteasy
 Spring MVC
 Spring Boot
CXF server stub
Features
 Since 2.2.2 (released 2017-03-01)
 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
 Run using Spring Integrationtests using random
ports
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
 io.swagger.codegen.Codegen
-i hello_world.json
-l jaxrs-cxf
-o c:hello_world_project
-c hello_world_config.json
Demo
 Create hello world service
 GenerateCXF server stub (with Spring
support enabled)
 Run using Spring Boot
 Run Junit-Tests
 Deploy to application server (Jboss EAP 7)
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
Generated Code – Hints
 Enum references supported (for models)
 Inheritance supported (but merged from
parent classes)
 BeanValidation
(@Min/@Max/@Size/@Pattern/@Valid)
 Builder pattern for models:
 return new Response().name(“Foo").first(“Test”);
 Optionally use JaxRs-Response instead of
return datatypes (useGenericResponse-flag)
Further development
life cycle
 Extend the API
 code first
 Freeze the contract
 Use theAPI
 Frontend development
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:
 Generate only interfaces/models
 Prevent accidential changes of theAPI
 Integrate in build job (Maven / Gradle)
 Specify which sources should NOT be
generated during build using .swagger-
codegen-ignore
 https://github.com/swagger-api/swagger-
codegen/tree/master/modules/swagger-codegen-maven-plugin
Freeze your API: maven
configuration
Demo
 Extend hello world service
(+ BeanValidation)
 Access updated specs
 Freeze the contract
Use your API
 Generate client stubs
 Swagger-Codegen
 Access your API using a browser
 Swagger-UI
 Generate HTML/PDF documentation
 Swagger2Markup
Why generate client code?
 No more manual api calls
 Ensure consistency of your client code with
theAPI!
 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 asWeb-Jar
https://github.com/swagger-api/swagger-ui
Swagger-UI
Swagger2Markup
 By RobertWinkler (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
Swagger2Markup
Improve the docs
 Automatically added:
 Since 1.0.1:Validation constraints are added
automatically to the properties
 Example values for Models are added as Example
HTTP responses
 „Polymorphism: Composition“ added for
inheriting models
 Manually: Add description to your models
and operations
Demo
 Client stub generator:
 Java
 Swagger-UI
 Swagger2Markup
Customize the generator
 Generator implemented in Java (one class for
each language)
 Mustache-files
 api.mustache
 apiServiceImpl.mustache
 pojo.mustache
 api_test.mustache
 …
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
WADL?
From WADL to Swagger
 Use wadl2java to generate server stub
 BeanValidation: krasa-jaxb-tools
 Activate CXF3 SwaggerFeature
 Use generated Swagger-file
 Will include BeanValidation annotations for
models
Swagger-Codegen – What‘s
next for CXF
 Support for OpenAPI 3.0 (issue 6517)
 Follow/Generate schema references
(and external schema references…)
 And keep them in the generated sources…
 True Polymorphism/inheritance
(currently merged from parents)
 Dynamic merge of new methods for
implementation + tests
 ???
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
 OpenAPI
 Join the technical developer community
 Swagger-Codegen
 Java / JMustache
 Swagger-UI
 Javascript
 Swagger-Editor
 Javascript
 RepreZen Eclipse KaiZen
 Java
 Swagger2Markup
 Java/Asciidoctor
Thank you for your
attention!
 Demo-Code:
http://github.com/jfiala/swagger-cxf-demo
 Contact:
 @johannes_fiala
Links & Resources
 Swagger Editor
 http://editor.swagger.io/
 RepreZen Eclipse KaiZen Plugin
 https://github.com/RepreZen/KaiZen-OpenAPI-Editor
 Swagger Codegen
 https://github.com/swagger-api/swagger-codegen
 Swagger UI
 https://github.com/swagger-api/swagger-ui
 CXF
 http://cxf.apache.org/

More Related Content

PDF
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
PPTX
Iterative Development with Swagger on the JDK
PDF
Swagger code motion talk
PDF
Swagger 2.0: Latest and Greatest
PPTX
Document your rest api using swagger - Devoxx 2015
PDF
OpenAPI Specification概要
PDF
Apache Continuum Build, Test, and Release
PDF
GitBucket: The perfect Github clone by Scala
How to generate a REST CXF3 application from Swagger ApacheConEU 2016
Iterative Development with Swagger on the JDK
Swagger code motion talk
Swagger 2.0: Latest and Greatest
Document your rest api using swagger - Devoxx 2015
OpenAPI Specification概要
Apache Continuum Build, Test, and Release
GitBucket: The perfect Github clone by Scala

What's hot (20)

PDF
Apache Big Data Europe 2015: Selected Talks
PDF
Asp.Net Core MVC , Razor page , Entity Framework Core
PPTX
Introduction to ASP.NET Core
PDF
Vagrant Binding JayDay 2013
PDF
Simple REST-APIs with Dropwizard and Swagger
PDF
Learning chef
PPTX
Swagger 2.0 and Model-driven APIs
PDF
Swagger for-your-api
PPTX
Web Performance & Latest in React
PPTX
Jenkins and AWS DevOps Tools
PDF
Node.js to the rescue
PPTX
Understanding how to use Swagger and its tools
PDF
Render-as-You-Fetch
PPTX
Introducing ASP.NET Core 2.0
PDF
Drone Continuous Integration
PDF
Securing Legacy CFML Code
PDF
Spring Dynamic Modules for OSGi by Example - Martin Lippert, Consultant
PPTX
Getting started with spfx
PDF
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
PPTX
ASP.NET Core 1.0 Overview
Apache Big Data Europe 2015: Selected Talks
Asp.Net Core MVC , Razor page , Entity Framework Core
Introduction to ASP.NET Core
Vagrant Binding JayDay 2013
Simple REST-APIs with Dropwizard and Swagger
Learning chef
Swagger 2.0 and Model-driven APIs
Swagger for-your-api
Web Performance & Latest in React
Jenkins and AWS DevOps Tools
Node.js to the rescue
Understanding how to use Swagger and its tools
Render-as-You-Fetch
Introducing ASP.NET Core 2.0
Drone Continuous Integration
Securing Legacy CFML Code
Spring Dynamic Modules for OSGi by Example - Martin Lippert, Consultant
Getting started with spfx
Creating applications with Grails, Angular JS and Spring Security - G3 Summit...
ASP.NET Core 1.0 Overview
Ad

Similar to Jcon 2017 How to use Swagger to develop REST applications (20)

PPTX
How to generate a rest application - DevFest Vienna 2016
PPTX
Consuming Restful APIs using Swagger v2.0
PPTX
Swagger - Making REST APIs friendlier
PPTX
Contract driven development
PPTX
Grails with swagger
PDF
Streamlining API with Swagger.io
PDF
Swagger / Quick Start Guide
PDF
[WSO2Con EU 2018] OpenAPI Specification 3 - The Evolution of Swagger
ODP
Introduction to Swagger
PPTX
Rest api code completion for javascript - dotjs 2015
PDF
Documenting your REST API with Swagger - JOIN 2014
PPTX
Swagger APIs for Humans and Robots (Gluecon)
PPTX
Swagger - make your API accessible
PPTX
API Design first with Swagger
PDF
Swagger - Make your REST APIs accessible - Victor Trakhtenberg
PPTX
SVQdotNET: Building APIs with OpenApi
PPTX
Rest API with Swagger and NodeJS
PDF
Swagger With REST APIs.pptx.pdf
PPTX
Everybody loves Swagger
PPTX
Introducing swagger
How to generate a rest application - DevFest Vienna 2016
Consuming Restful APIs using Swagger v2.0
Swagger - Making REST APIs friendlier
Contract driven development
Grails with swagger
Streamlining API with Swagger.io
Swagger / Quick Start Guide
[WSO2Con EU 2018] OpenAPI Specification 3 - The Evolution of Swagger
Introduction to Swagger
Rest api code completion for javascript - dotjs 2015
Documenting your REST API with Swagger - JOIN 2014
Swagger APIs for Humans and Robots (Gluecon)
Swagger - make your API accessible
API Design first with Swagger
Swagger - Make your REST APIs accessible - Victor Trakhtenberg
SVQdotNET: Building APIs with OpenApi
Rest API with Swagger and NodeJS
Swagger With REST APIs.pptx.pdf
Everybody loves Swagger
Introducing swagger
Ad

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced Soft Computing BINUS July 2025.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Machine learning based COVID-19 study performance prediction
CIFDAQ's Market Insight: SEC Turns Pro Crypto

Jcon 2017 How to use Swagger to develop REST applications

  • 1. (HOW TO) USE SWAGGER TO DEVELOP REST APPLICATIONS @johannes_fiala - JCON 2017
  • 2. About me…  Swagger-CodegenContributor  Javascript, Jaxrs-CXF, BeanValidation for Java*, Jaxrs-Resteasy  Other contributions  Spring REST / Swagger-Springfox  BeanValidation support  Swagger2Markup  BeanValidation support
  • 3. Agenda  Generate based on contract  Extend using code first  Freeze the contract  Use the RESTAPI  Generate client code (Java/Javascript)  Access with a browser using a UI  View/Share as HTML/PDF  Customize the code generator
  • 4. Toolchain  ApacheCXF 3  + SwaggerFeature  + Spring integration/Spring Boot integration  Swagger-Tools  Swagger-Editor / Eclipse KaiZen Plugin  Swagger-Codegen  Swagger-UI  Swagger2Markup
  • 5. Contract first, then code, then contract …
  • 7. Contract spec. formats  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  Version: 3.0 (released 2017-07)  Others: Blueprint, RAML, …
  • 8. Open API / Swagger  A language-agnostic interface to RESTAPIs  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  Neu: KaiZen – für OpenAPI 2 + 3  Templates nur fürYaml, nicht für Json  CommercialTools:  Restlet Studio  RepreZenAPI Studio
  • 11. Eclipse + KaiZen Plugin  Open Source  https://github.com/RepreZen/KaiZen-OpenAPI-Editor  Swagger 2 + 3  Supports onlyYAML format  Navigation  Outline  + Navigate using Ctrl+Click  Templates  Scope-specific  Completely Customizable!
  • 13. Eclipse + KaiZen Plugin Templates
  • 14. Eclipse + KaiZen Plugin  Demo
  • 15. Swagger-Codegen  by SmartBear (Apache License)  Version 2.2.3  Java program  + Mustache templating  Generates server + client code  Currently supports OpenAPI v2 !  Support for 3.0 in progress…, see #6517 https://github.com/swagger-api/swagger-codegen
  • 16. Swagger-Codegen Supported Languages  Client and/or Server available for:  Android,Asp.net, AsyncScala, Bash, Clojure,ConfluenceWiki, C++, C#, Dart, Elixir, Erlang, Finch, Flash, FlaskConnexion, Go, Groovy, Haskell, Java,CXF, JavaInflector, Jaxrs-Spec, Jersey, JavaMSF4J, Resteasy, Javascript,AngularJS, Jmeter, Lumen, NancyFX, NodeJS, ObjC, Perl, Php, Python,Qt5C++, Rails, Ruby, Scala, Scalatra, Silex, Sinatra, Slim (PHP), Spring, Static Html, Swagger,Yaml, Swift,Tizen,TypescriptAngular, Undertow, …  And many more libraries (e.g. Java Jersey1, ok-http-gson, …)
  • 18. Generate the server stub Swagger-Codegen  Supported server stubs for Java:  Java JAX RS  2.0 spec  Jersey  CXF (Spring/CDI)  Resteasy  Spring MVC  Spring Boot
  • 19. CXF server stub Features  Since 2.2.2 (released 2017-03-01)  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  Run using Spring Integrationtests using random ports
  • 20. 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)
  • 21. Swagger-Codegen CLI  io.swagger.codegen.Codegen -i hello_world.json -l jaxrs-cxf -o c:hello_world_project -c hello_world_config.json
  • 22. Demo  Create hello world service  GenerateCXF server stub (with Spring support enabled)  Run using Spring Boot  Run Junit-Tests  Deploy to application server (Jboss EAP 7)
  • 23. 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
  • 24. Generated Code – Hints  Enum references supported (for models)  Inheritance supported (but merged from parent classes)  BeanValidation (@Min/@Max/@Size/@Pattern/@Valid)  Builder pattern for models:  return new Response().name(“Foo").first(“Test”);  Optionally use JaxRs-Response instead of return datatypes (useGenericResponse-flag)
  • 25. Further development life cycle  Extend the API  code first  Freeze the contract  Use theAPI  Frontend development
  • 26. Extend the application  Modify your API:  Add new services (use JAXRS-annotations)  Use Swagger annotations  Use BeanValidation annotations  Generated Swagger spec gets updated automatically
  • 27. Extend the application Swagger annotations  Service:  @Api – activate Swagger for api  Operations:  @ApiOperation - description  @ApiResponse – error codes + return types  Model:  @ApiModel - description  @ApiModelProperty - description
  • 28. Freeze your API:  Generate only interfaces/models  Prevent accidential changes of theAPI  Integrate in build job (Maven / Gradle)  Specify which sources should NOT be generated during build using .swagger- codegen-ignore  https://github.com/swagger-api/swagger- codegen/tree/master/modules/swagger-codegen-maven-plugin
  • 29. Freeze your API: maven configuration
  • 30. Demo  Extend hello world service (+ BeanValidation)  Access updated specs  Freeze the contract
  • 31. Use your API  Generate client stubs  Swagger-Codegen  Access your API using a browser  Swagger-UI  Generate HTML/PDF documentation  Swagger2Markup
  • 32. Why generate client code?  No more manual api calls  Ensure consistency of your client code with theAPI!  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 asWeb-Jar https://github.com/swagger-api/swagger-ui
  • 35. Swagger2Markup  By RobertWinkler (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. Swagger2Markup Improve the docs  Automatically added:  Since 1.0.1:Validation constraints are added automatically to the properties  Example values for Models are added as Example HTTP responses  „Polymorphism: Composition“ added for inheriting models  Manually: Add description to your models and operations
  • 38. Demo  Client stub generator:  Java  Swagger-UI  Swagger2Markup
  • 39. Customize the generator  Generator implemented in Java (one class for each language)  Mustache-files  api.mustache  apiServiceImpl.mustache  pojo.mustache  api_test.mustache  …
  • 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
  • 42. WADL? From WADL to Swagger  Use wadl2java to generate server stub  BeanValidation: krasa-jaxb-tools  Activate CXF3 SwaggerFeature  Use generated Swagger-file  Will include BeanValidation annotations for models
  • 43. Swagger-Codegen – What‘s next for CXF  Support for OpenAPI 3.0 (issue 6517)  Follow/Generate schema references (and external schema references…)  And keep them in the generated sources…  True Polymorphism/inheritance (currently merged from parents)  Dynamic merge of new methods for implementation + tests  ???
  • 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  OpenAPI  Join the technical developer community  Swagger-Codegen  Java / JMustache  Swagger-UI  Javascript  Swagger-Editor  Javascript  RepreZen Eclipse KaiZen  Java  Swagger2Markup  Java/Asciidoctor
  • 46. Thank you for your attention!  Demo-Code: http://github.com/jfiala/swagger-cxf-demo  Contact:  @johannes_fiala
  • 47. Links & Resources  Swagger Editor  http://editor.swagger.io/  RepreZen Eclipse KaiZen Plugin  https://github.com/RepreZen/KaiZen-OpenAPI-Editor  Swagger Codegen  https://github.com/swagger-api/swagger-codegen  Swagger UI  https://github.com/swagger-api/swagger-ui  CXF  http://cxf.apache.org/