Using Swagger to Generate Client SDKs for REST APIs

Home » Blog » Software » Enterprise Software » Using Swagger to Generate Client SDKs for REST APIs

These days Swagger is a popular, easy-to-use tool for (semi-)automatically documenting REST APIs on-the-fly. For example, in order to document a REST API created with Spring Boot and Jersey literally all you have to do is add these two entries to your Maven pom.xml:

		<dependency>
			<groupid>io.springfox</groupid>
			<artifactid>springfox-swagger2</artifactid>
			<version>2.6.1</version>
		</dependency>
		<dependency>
			<groupid>io.springfox</groupid>
			<artifactid>springfox-swagger-ui</artifactid>
			<version>2.6.1</version>
		</dependency>

You’ll then get a ready-made documentation for all your REST API endpoints. An example of how this looks like can be seen here.

While this already is very useful in that it helps with properly documenting your software, especially that part of it that will be consumed by other components, another, probably lesser-known feature of Swagger or rather part of the Swagger tool suite is Swagger Codegen (source code available here), which allows you to generate client SDKs for REST APIs documented with Swagger.

Supporting a wide variety of languages (currently more than 20) and client frameworks Swagger Codegen not only removes tedious plumbing from the development process but also provides tried and tested code for accessing REST APIs, which helps tremendously with improving the reliability and maintainability of client code.

Instead of constantly re-inventing the wheel when dealing with REST APIs you can just have Swagger Codegen create REST API servicing code for you.

Leave a Comment

By continuing to use the site you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or if you click "Accept" below then you are consenting to this.

Close