Writer APIs in Java faster with Swagger Inflector

17
Iterative Development with Swagger on the JDK Tony Tam @fehguy

Transcript of Writer APIs in Java faster with Swagger Inflector

Page 1: Writer APIs in Java faster with Swagger Inflector

Iterative Developmentwith Swagger on the JDK

Tony Tam

@fehguy

Page 2: Writer APIs in Java faster with Swagger Inflector

Swagger Codegen

• Creation of Clients, Servers from Swagger Spec– 5 servers

• Java, Scala, PHP, node.js

– 19 clients• Android, Scala, C#, Java, Objective-C, Perl, PHP,

Python, QT-CPP, Retrofit, Ruby, HTML, Swift, Tizen, Typescript Angular

– Nearly unlimited workflow integration possibilities

Page 3: Writer APIs in Java faster with Swagger Inflector

Workflow-Specific Configuration

• Customized class + templates

Server

Docker Image

ObjC Client

Java Client

Re-generation with ChangesAPM integration with NewrelicOps integration with DataDog

Configured name, versionsPush to docker repo via Jenkins build

PodfilePush to github repo on Jenkins Build

ArtifactPush to Maven Repo on Jenkins Build

Page 4: Writer APIs in Java faster with Swagger Inflector

Workflow-Specific Configuration

• Independent Iterations from single definition

Design+

CollaborateGenerate

ImplementClient

ImplementLogic

Iterate

Iterate

Deploy

Deploy

Page 5: Writer APIs in Java faster with Swagger Inflector

So What’s Broken?

• Nothing really! But…– Source Code collisions can be avoided– What’s the source of truth?– How do non-engineers improve

documentation?

• Not to nitpick but…

Page 6: Writer APIs in Java faster with Swagger Inflector

So What’s Broken?

Page 7: Writer APIs in Java faster with Swagger Inflector

Specification-Driven Development

• The Swagger Specification should be the source of truth– No round-trips to/from codegen– No out-of-date server based on code changes

Page 8: Writer APIs in Java faster with Swagger Inflector

Swagger-Inflector

• A new Friction Reducer• Programmatic endpoint generation• Your new Plumber

Page 9: Writer APIs in Java faster with Swagger Inflector

How it Works

• Write your Specification• Inflector wires your spec to the server• Endpoints have automatic sample data• Implementation is simply writing

controllers• Based on JAX-RS 2.0, Jersey 2.6

Page 10: Writer APIs in Java faster with Swagger Inflector

Inflector Workflow

Design+

Collaborate

Generate ImplementClient

ImplementLogic

Iterate

Iterate

Deploy

Deploy

Page 11: Writer APIs in Java faster with Swagger Inflector

Focus on Business Logic!inflector.yaml

swagger.yaml

Page 12: Writer APIs in Java faster with Swagger Inflector

Iterative Development!

• Unimplemented methods return mock data

application/xml

application/json

Page 13: Writer APIs in Java faster with Swagger Inflector

Complex Schemas

Page 14: Writer APIs in Java faster with Swagger Inflector

Shut up already!

• DEMO

Page 15: Writer APIs in Java faster with Swagger Inflector

Stop Plumbing!

Remove Redundant

Logic

Page 16: Writer APIs in Java faster with Swagger Inflector

State of the Project

• Preview available!– https://github.com/swagger-api/swagger-inflec

tor

• Plenty to do!• Will become a fully supported part of

Swagger• More Samples soon

Page 17: Writer APIs in Java faster with Swagger Inflector

• Questions?