Swagger: A Roundtrip Tool For Creating And Consuming REST APIs

Home » Blog » Software » Enterprise Software » Swagger: A Roundtrip Tool For Creating And Consuming REST APIs

In this second part of my series on useful tools for developing CRUD applications I’d like to introduce Swagger and Swagger Codegen in particular. Introduce perhaps isn’t exactly the right word because first of all Swagger is quite well known in developer circles these days. Secondly, a few months ago I wrote a blog post about how to use Swagger to generate client SDKs for REST APIs.

Swagger – originally having originated at Wordnik is a tool for documenting and publishing their own dictionary API – today essentially is a tool suite covering various aspects of REST APIs and API definition and documentation in particular. In March 2015 the open source project was acquired by API testing and development tools provider SmartBear (of SoapUI fame). SmartBear continue to develop Swagger and have since started the Open API Initiative (OAI), which now includes big players like Google, Microsoft, PayPal and IBM. The purpose of this initiative is to provide a standardised way for describing REST APIs in a vendor-independent manner. The Swagger Specification donated by SmartBear serves as the foundation for this endeavour.

Among various accompanying and libraries for countless languages and frameworks Swagger itself consists of these 3 core tools:

  • Swagger Editor: An IDE for describing your API in a JSON format. Once your API description is done you can directly generate server code for this API from the IDE!
  • Swagger Codegen: As mentioned earlier Swagger Codegen can be used to generate client SDKs for accessing Swagger-defined REST APIs. Supporting a wide variety of languages (currently more than 20) all the Swagger Codegen command-line tool needs is a Swagger API definition in order to generate client code for consuming your REST API.
  • Swagger UI: The probably most well-known tool from the Swagger toolbox. Swagger UI automatically creates an interactive HTML documentation from Swagger API definitions. Not only does Swagger UI provide you with a more or less effortless way of supplying documentation for your APIs but it also lets your users call and explore these APIs directly from the browser. No complex and tedious curl calls required anymore!

Swagger is conducive to building CRUD applications because it makes describing and provide access to data models a breeze. For vanilla CRUD applications that need just that and no extra business logic Swagger and its supplementary libraries probably are entirely sufficient and you quite likely won’t even have to write a single line of code (apart from the Swagger API definition that is)!

About the author: Bjoern
Independent IT consultant, entrepreneur

Leave a Comment