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

* Checkbox GDPR is required

*

I agree

By continuing to browse the site you agree to our use of cookies. Privacy Policy

Privacy Preference Center

Strictly necessary

These cookies are necessary for the site to function.

PHPSESSID: Preserves user session state across page requests.

__cfduid: Used by the content network, Cloudflare, to identify trusted web traffic.

PHPSESSID
__cfduid

Preferences

Remembers the user's submitted data when a comment is submitted in a blog post. The purpose is to aut o-populate form fields for subsequent comments, in order to save time for the user.

wfvt_#

Statistics

Statistic cookies help us to understand how visitors interact with our websites by collecting and reporting information anonymously.

_ga: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

_gat: Used by Google Analytics to throttle request rate.

_gid: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

collect: Used to send data to Google Analytics about the visitor's device and behaviour. Tracks the visitor across d evices and marketing channels.

_ga,_gat,_gid
collect

Security

We use Wordfence to secure our website against hacking attempts: https://www.wordfence.com/

wordfence_verifiedHuman

Close your account?

Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?