Skip to content
Gradle plugin to generate Java server and client code based on Swagger/OpenAPI yaml files.
Groovy HTML Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
gradle
src
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

swagger-gradle-plugin Build Status

Gradle plugin to generate Java server and client code based on Swagger/OpenAPI yaml files.

Motivation

In a microservice world you need to provide some communication layer between your services. If you are choosing REST API the workflow is usually the following: in service A(producer) you create REST controllers and some DTOs to describe you API. In service B(consumer) you create the same DTOs and some code to call the A's endpoints. If requirements are changed you need to make modifications in both services. If there are multiple consumers there is a big chance that you forgot to modify one of them.

The AIM of this plugin is to solve this issue and to generate some boilerplate for you communication layer.

Usage

First step is to add the plugin to your project as described here.

Next step is to write specification of you API in Swagger/OpenAPI yaml format. Swagger editor is really helpful for this task.

Tips and tricks

Splitting specification

You can split you specification yaml file into multiple files. Plugin will automatically merge them into a single file (duplicate paths\definitions will be merged).

You can use swaggers tag key in the specification to group you endpoints.

You can’t perform that action at this time.