openapi-client-generation

Configure OpenAPI Generator in Gradle to auto-generate Java REST client classes from an api.yml spec.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/heiherilala-vawd/ompany-Management --skill openapi-client-generation-heiherilala-vawd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-client-generation
Source: https://github.com/heiherilala-vawd/ompany-Management/tree/main/.agents/skills/openapi-client-generation
Command: npx skills add https://github.com/heiherilala-vawd/ompany-Management --skill openapi-client-generation-heiherilala-vawd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Manually writing Java client code, DTOs, and HTTP invokers for a REST API is repetitive and error-prone. This Skill automates the full setup of OpenAPI Generator in a Spring Boot Gradle project so client classes are generated directly from your OpenAPI specification and wired into the build. ## Core Features & Use Cases - Gradle Plugin Configuration: Sets up the org.openapi.generator plugin with a generateJavaClient task, including package mappings, type mappings (Date to LocalDate, DateTime to Instant), and Jackson serialization. - Build Pipeline Integration: Publishes generated code to the local Maven repository via shell/batch scripts and makes compileJava depend on generation, so the client is always up to date. - Code Quality Exclusions: Excludes generated client code from Spotless, Checkstyle, and JaCoCo coverage. - Use Case: You maintain an api.yml as the single source of truth for your Spring Boot API. Use this Skill to auto-generate the Java client (api, invoker, model packages) on every build without hand-writing DTOs. ## Quick Start Set up OpenAPI Generator in my Spring Boot Gradle project to generate a Java client from src/main/resources/api/api.yml.

Frequently Asked Questions about openapi-client-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a Java client from an OpenAPI spec in Gradle?

Add the org.openapi.generator plugin to build.gradle.kts and register a GenerateTask pointing inputSpec at your api.yml file. Set apiPackage, invokerPackage, and modelPackage to control where the generated api, invoker, and model classes are placed.

How to make compileJava depend on OpenAPI client generation?

Register a publishJavaClientToMavenLocal Exec task that depends on generateJavaClient, then make the compileJava task depend on it. This ensures the generated client is published to the local Maven repository before compilation runs.

Does OpenAPI Generator support Java time types like LocalDate?

Yes, use typeMappings in the GenerateTask configuration to map OpenAPI Date to java.time.LocalDate and DateTime to java.time.Instant. Also set dateLibrary to custom and serializationLibrary to jackson in configOptions.

How do I exclude generated code from JaCoCo and Spotless?

Add targetExclude patterns for **/client/**, **/gen/**, and **/generated/** in your Spotless configuration. For JaCoCo, filter classDirectories with a fileTree that excludes the client, model, api, and invoker packages.

Why does my build fail after adding OpenAPI client generation?

Builds commonly fail when the generated client is not published to the local Maven repository before compilation, or when the publish script lacks execute permissions. Run chmod +x on the shell script and verify the task dependency chain from compileJava to generateJavaClient.