Exploring Swagger Codegen and Swagger Plugins

Design first or code first, its your call

Jennifer Fu
CodeX

--

A scene at Nola’s Iris Garden
Image credit: Author

We have introduced the OpenAPI Specification, Swagger Editor, and Swagger UI. Let’s look further into Swagger Codegen and Swagger Plugins.

Swagger Codegen starts with the OpenAPI Specification (OAS), and performs two actions:

  • Generate server stubs.
  • Generate client SDKs.

In this article, we focus on how to generate server stubs. We will talk about how to generate client SDKs in another article.

Generating server stubs is the design first approach, which starts with the OpenAPI Specification, YAML or JSON defined APIs on resources, operations, and data models. Once the design is complete, the business logic is implemented based on the generated server stubs. This process is further automated by SwaggerHub, which is an enterprise version Swagger tool. Here, we go through the manual generating process to understand more details.

There is also the code first approach, which build business logic first. Based on the existing API implementation, Swagger plugins generates the OpenAPI Specification.

In general, the design first approach is recommended by the Swagger community. The code first approach is adopted by organizations…

--

--