Skip to content

redhat-appdev-practice/vertx-openapi-jooq-multimodule

Repository files navigation

OpenAPI Contract-First with Vert.x and jOOQ

Overview

The purpose of this project is to demonstrate how you could create a Contract-First API for Vert.x using OpenAPI Generator and jOOQ

WHAT IS GOING ON HERE?!?!?!

Great question! At first glance, it seems somewhat complicated doesn't it?!?! Once you get past that, it's really not so bad. Here's how it works:

  1. You start with an OpenAPI Specification file (the contract) HERE
  2. Using that contract, the modules/data-access module uses the OpenAPI Generator to create SQL DDL for the schema classes
  3. The jOOQ Maven Plugin then generates the jOOQ code needed to wire our data types to the database using the Vert.x jOOQ custom generator.
  4. The DAOs created by the jOOQ generator are then used to implement our Service Classes in the modules/api module

The modules/converters module is purely to allow for the creation/compilation of the jOOQ custom type converters, and if you are not using UUIDs as your primary key you shouldn't need to worry about it.

TL;DR - Ignore everything except the modules/api module. Everything that we will be doing as developers will happen in that module alone. Everything else is tooling/automation so that we get a bunch of stuff done for us for free.

Prerequisites

  • Java JDK 17
  • Docker (or Podman >=3.3 and docker socket configured)
  • Docker Compose

Build Application

mvn clean verify

Run application locally

docker-compose up -d
mvn clean install
mvn -pl modules/api clean compile vertx:run

Swagger UI

Swagger UI has been integrated and is expose on port 8080 at the path /swagger/. When running locally, this would be http://localhost:8080/swagger/