December 6th, 2017

API-driven development with OpenAPI and Swagger, Part 2

APIs, Development Tools, Java App Dev, Java Web Development, others, Programing, Spring Framework, by admin.

The first half of this article introduced the big picture of APIs–such as how they fit into application development, cloud and microservices architectures, and the role of API specs like OpenAPI. You were introduced to OpenAPI and we developed a simple example application built from an API definition.

In this article we’ll continue developing our API definitions and application code with OpenAPI and Swagger, and we’ll throw Swing Web MVC and Angular 2 into the mix. By the end of the article, we’ll have used Swagger tools to both generate OpenAPI from a Spring MVC app, and generate an Angular frontend from an OpenAPI specification. You will be familiar with the core Swagger tools, and you’ll know how to use them to build your own API-driven web apps.

Swagger and OpenAPI

As you might recall from Part 1, Swagger and OpenAPI are closely related. In fact, Swagger started out as the API definition language now known as OpenAPI. Over time, Swagger has evolved into a rich ecosystem of related projects, each one supporting the OpenAPI specification. Swagger includes a visual API designer and a handful of commercial integration products that are built on top of open source components.

API definitions

In Part 1, I explained the distinction between prescriptive and descriptive API use. In a prescriptive definition, the API drives code creation, whereas in a descriptive definition, we use code to generate the API. You also might see this distinction described in terms of design-first or implementation-first API usage. Both styles are valid and useful, and they are equally supported by tooling. We’ll use both prescriptive and descriptive API definitions in this article.

Back Top

Leave a Reply