A: This is a comprehensive Gradle plugin that wraps the OpenAPI Generator with enhanced features specifically for generating Java DTOs. It adds multi-spec support, template customization via YAML, performance optimizations, and enterprise-grade features like template libraries and incremental builds.
A: Key differences include:
A: Yes, you must apply the OpenAPI Generator plugin first. This plugin enhances and wraps the OpenAPI Generator, it doesn’t replace it:
plugins {
id 'org.openapi.generator' version '7.14.0' // Required first
id 'com.guidedbyte.openapi-modelgen' version '2.1.0' // Then this plugin
}
A: The plugin supports OpenAPI Generator versions 7.10.0 and above. It’s tested with:
The plugin automatically detects your OpenAPI Generator version and adapts accordingly.
A:
A: Yes! The plugin is fully compatible with Gradle’s configuration cache. Use it for maximum build performance:
./gradlew generateAllModels --configuration-cache
A: Yes, the plugin defaults to Spring Boot 3 configuration:
A: The plugin works with any OpenAPI Generator, including:
The plugin adapts to your chosen generator automatically.
= in configuration?A: This plugin uses method-call syntax instead of assignment syntax:
✅ Correct - Method call syntax
openapiModelgen {
defaults {
outputDir "build/generated" // Method call
validateSpec true // Method call
}
}
❌ Wrong - Assignment syntax (compilation error)
openapiModelgen {
defaults {
outputDir = "build/generated" // Will fail
validateSpec = true // Will fail
}
}
This enables type validation, CLI overrides, and better error reporting.
A: Yes, all configuration options support command-line overrides:
# Override output directory
./gradlew generateAllModels --output-dir=src/generated
# Enable validation
./gradlew generateApi --validate-spec=true
# Override model package
./gradlew generateApi --model-package=com.custom.model
A: Use the specs block to define multiple specifications:
openapiModelgen {
specs {
users {
inputSpec "src/main/resources/openapi/users.yaml"
modelPackage "com.example.users.model"
}
orders {
inputSpec "src/main/resources/openapi/orders.yaml"
modelPackage "com.example.orders.model"
}
}
}
Each spec gets its own generation task: generateUsers, generateOrders, plus generateAllModels. Each spec also gets its own isolated template directory to prevent cross-contamination between different specifications.
A:
.mustache files that replace the entire templateUse YAML customizations for most cases - they’re easier to maintain and survive OpenAPI Generator updates.
A: Common causes:
Explicit template exists: If you have both an explicit template AND YAML customization for the same template, the explicit template takes precedence and YAML is ignored.
✅ Correct
src/main/resources/template-customizations/spring/pojo.mustache.yaml
❌ Wrong
src/main/resources/template-customizations/pojo.mustache.yaml
build/template-work/spring-{specName}/A: No! Each spec gets its own isolated template working directory:
build/template-work/spring-users/build/template-work/spring-orders/This prevents template cross-contamination and allows each spec to have different template customizations even when using the same generator (e.g., spring).
A: Yes! Use template libraries:
Create a library JAR with templates in META-INF/openapi-templates/ and customizations in META-INF/openapi-customizations/
dependencies {
openapiCustomizations 'com.company:api-templates:1.0.0'
}
openapiModelgen {
defaults {
useLibraryTemplates true
useLibraryCustomizations true
templatePrecedence([
'user-templates',
'library-templates',
'user-customizations',
'library-customizations',
'plugin-customizations',
'openapi-generator'
])
}
}
A: Access comprehensive debug information:
openapiModelgen {
defaults {
// No logging configuration needed - rich debug log always captured
}
}
# View rich debug log (always available)
cat build/logs/openapi-modelgen-debug.log
# Filter by specific spec
grep "[spec:mySpec]" build/logs/openapi-modelgen-debug.log
# Use standard Gradle flags for console output
./gradlew generateApi --info
# Check template working directory (replace {specName} with your spec name)
ls -la build/template-work/spring-{specName}/
A: Several optimization strategies:
./gradlew generateAllModels --configuration-cache
openapiModelgen {
defaults {
parallel true // Default: true
}
}
openapiModelgen {
defaults {
generateModelTests false // Skip if not needed
generateApiDocumentation false // Skip if not needed
validateSpec false // Skip in development (enable in CI)
}
}
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
A: This is normal! The plugin uses multi-level caching:
A: The plugin uses a three-level cache hierarchy:
~/.gradle/caches/openapi-modelgen/Cache automatically invalidates when specs, templates, or plugin version changes.
A: Ensure you apply the OpenAPI Generator plugin first:
plugins {
id 'org.openapi.generator' version '7.14.0' // Must be first
id 'com.guidedbyte.openapi-modelgen' version '1.1.1'
}
A: Common causes:
components.schemasvalidateSpec trueA: Usually missing dependencies:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'io.swagger.core.v3:swagger-annotations:2.2.19'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
A: Common YAML issues:
❌ Wrong indentation
insertions:
- after: "pattern"
content: "text"
✅ Correct indentation
insertions:
- after: "pattern"
content: "text"
❌ Unquoted Mustache patterns
conditions:
templateContains:
✅ Properly quoted
conditions:
templateContains: ""
A: Yes! The plugin is designed for enterprise use:
A: Migration steps:
= signs)openApiGenerate → generateApiName)A: Yes! Check the GitHub repository for contribution guidelines:
CLAUDE.mdA: Multiple support channels:
./gradlew generateHelp for configuration referenceA: Several ways:
# Check plugin version
./gradlew buildEnvironment | grep openapi-modelgen
# Get comprehensive help (includes version info)
./gradlew generateHelp
# Check dependencies
./gradlew dependencyInsight --dependency com.guidedbyte.openapi-modelgen
A: Update the version in your build.gradle:
plugins {
id 'com.guidedbyte.openapi-modelgen' version '1.1.1' // Update version
}
Check the release notes for any breaking changes or new features.
A: The plugin follows semantic versioning:
Always check the release notes and migration guide when upgrading.
Still have questions? Check the complete documentation or open a GitHub issue.