Couchbase incorporated Swagger into our documentation a few months ago. “Swagger” refers to an ecosystem of tools and other resources for managing REST APIs.

Core to Swagger is the Swagger specification. (The group behind Swagger donated the spec to the OpenAPI Initiative. The original site, swagger.io remains the main site for tools and such.)

Once you have the API spec defined for you endpoints, you get several valuable capabilities. My two favorite are the “live” embeddable documentation and the client libraries. Take a look at this short video for a demonstration of some of the features of Swagger.

For an example of using a Swagger JavaScript client, take a look at this blog post: https://blog.couchbase.com/node-js-swagger-monitor-document-changes-couchbase-mobile/

You can find the Swagger specs for the Sync Gateway public API here, and the admin API here.

Here are the Sync Gateway configurations I refer to in the video. The first has the CORS configuration to allow access from swagger.io.

The second is for trying out calls through our live documentation.

(Note: There’s currently a known issue with making the calls from the Couchbase documentation. Couchbase now requires access via https, in keeping with security best practices. This means the documentation also redirects using https. This means you have to set up Sync Gateway to use SSL. See the documentation here for more information.)

Postscript

Download Couchbase and Sync Gateway here. See our documentation for how to add Couchbase Lite to a project.

Check out more resources on our developer portal and follow us on Twitter @CouchbaseDev.

You can post questions on our forums. And we actively participate on Stack Overflow.

Hit me up on Twitter with any questions, comments, topics you’d like to see, etc. @HodGreeley

Posted by Hod Greeley, Developer Advocate, Couchbase

Hod Greeley is a Developer Advocate for Couchbase, living in Silicon Valley. He has over two decades of experience as a software engineer and engineering manager. He has worked in a variety of software fields, including computational physics and chemistry, computer and network security, finance, and mobile. Prior to joining Couchbase in 2016, Hod led developer relations for mobile at Samsung. Hod holds a Ph.D. in chemical physics from Columbia University.

Leave a reply