Swagger to Server
Who is this for?
Anyone planning on making a HTTP API.
APIs as a Product
"...what differentiates an API from an ordinary enterprise integration service? One difference lies in treating APIs as a product, even when the consumer is an internal system. "
https://www.thoughtworks.com/radar/techniques/apis-as-a-product
Problem:
Keeping API documentation in sync with code.
Solution:
Generate code from API specification as data and use compile time checks to make sure it is in sync.
- Swagger specification
- Go compiler
While we're at it...
- boilerplate code
- deserialization/serialization
- validation!
Any existing solutions?
- go-swagger & goa
- very large
- mix generated & handwritten code
- generating swagger spec from code
Demo Time
Opinion Time
- don't touch generated code (or check it in)
- separate from transport/content-type asap
- API first; don't compromise due to implementation
- handle errors with panic()
The Bad
- framework vs library
- put in a box (EF, mongoose, .net)
- cross team dependency
Current State
- POC
- ...but not in a vacuum.
- V1 by Q1
Future
- Protocol Buffers
- less used swagger features
- documentation & seed repo
Swagger to Server
By Chris Langager
Swagger to Server
- 550