13
nomossoftware nomos-software.com Creating Java JAX-RS Servers from Swagger API definitions London Java Community Meetup, Docklands, Oct 2015 David Garry, CTO david.garry(at)nomos-software.com

Swagger and Code Generation

Embed Size (px)

Citation preview

Page 1: Swagger and Code Generation

nomossoftware nomos-software.com

Creating Java JAX-RS Servers from Swagger API definitions

London Java Community Meetup, Docklands, Oct 2015

David Garry, CTOdavid.garry(at)nomos-software.com

Page 2: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Contents

• Introduction to Swagger and REST meta-data formats

• Sample Swagger Document

• Editing Swagger Document using Swagger Editor

• Code generation using Swagger CodeGen

• Swagger Documentation Generation using Swagger-Core

• Usage of Swagger Editor at Nomos

• Swagger Hub

Page 3: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Introduction to Swagger

Swagger (http://swagger.io/) is a project used to describe and document RESTful APIs.Swagger project is open source and sponsored by Smartbear

• Swagger Specification - http://swagger.io/specification/

• Swagger Tooling - http://swagger.io/tools/

• Swagger Community - http://swagger.io/community/

Page 4: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

API Description Languages

Mainly uses XML Schema

Mainly usesJSON Schema

WADL

Swagger

RAML

API Blueprint

not used much

Sponsored by Smartbear, largest community, lots of tools

Sponsored by Mulesoft

Sponsored by Apiary

API Description Languages - Alternatives

Introduction to Swagger

Page 5: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Introduction to Swagger

Core Swagger Tools

https://github.com/swagger-api

https://github.com/swagger-api/swagger-core

https://github.com/swagger-api/swagger-ui

https://github.com/swagger-api/swagger-codegen/tree/develop_2.0

https://github.com/swagger-api/swagger.io/blob/wordpress/tools/swagger-editor.md

Page 6: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Sample Swagger Document – TMForum Product Mgt API

The data model for API request parameters and responses

Based on JSON schema

The paths / operations

POST product OrderGET product Order

Page 7: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Editing Swagger Document using Swagger Editor

Play with the editor at http://editor.swagger.io/#/

Page 8: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Code Generation using Swagger Codegen

Page 9: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Code Generation using Swagger Codegen

Data model generated from Definitions Section

Page 10: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Swagger Documentation Generation using Swagger-Core

Swagger-core exposes JAX-RS providers and one JAX-RS resource to generate and serve the Swagger API documentation

Page 11: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

RuleXMock+ Server

Swagger UI

Cloud Container

RuleX Swagger Editor

API Consumer

RuleX Code Generation for APIs

API Designer

RuleX code generation

interacts with

Swagger Descriptionpublish view

RuleX code generation

RuleX Test API Calls

Usage of Swagger at Nomos

More on RuleX Swagger Editor : http://nomos-software.com/blog/rulex-swagger-editorAvailable on github at https://github.com/nomos-software/swagger-editor-rulex

Page 12: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

SwaggerHub : https://swaggerhub.com/Hosted environment for your swagger : launched by Smartbearto provide Collaboration and Coordination across API Lifecycle

Page 13: Swagger and Code Generation

www.nomos-software.comCopyright © Nomoséire Limited 2015 trading as Nomos Software nomossoftware

Software Vendor

API Consultancy Services

Our RuleX product supports Swagger

About Nomos Software

Design, Test, Deploy, Document, API Tools Ecosystem etc

Contact: [email protected]

(slides available at http://www.slideshare.net/nomossoftware)