OpenAPITools / OpenAPITools/openapi-generator
[REQ] Is there a way to generate multiple specs in one project?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I want to generate multiple clients, and I am doing so with multiple tasks:
task javaOne(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName = "java"
inputSpec = "https://example.com/api1"
outputDir = "$buildDir/java/ApiOne"
configOptions = [hideGenerationTimestamp: true]
}
task javaTwo(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName = "java"
inputSpec = "https://example.com/api2"
outputDir = "$buildDir/java/ApiTwo"
configOptions = [hideGenerationTimestamp: true]
}
The problem is that this creates two seperate build packages (build/java/ApiOne and build/java/ApiTwo), which have lots of redundant stuff.
Describe the solution you'd like
I'm wondering if I could somehow compile clients for multiple specs in a single file, something like:
task javaAthlete(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName = "java"
inputSpecs = [
"https://example.com/api2",
"https://example.com/api1",
]
outputDir = "$buildDir/java/Api"
configOptions = [hideGenerationTimestamp: true]
}
resulting in a single build/java/Api directory. I see a similar topic discussed for swagger-codegen at the following url, but see no discussion/documentation about something similar with openapi-generator: https://stackoverflow.com/questions/41702500/generate-code-for-multiple-swaggers-in-the-same-project
Describe alternatives you've considered
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Gradle plugin's org.openapitools.generator.gradle.plugin.tasks.GenerateTask and review how inputSpec and outputDir are handled for separate tasks. Done means establishing whether multiple OpenAPI specs can produce one Java client package in a single output directory, with the required configuration and behavior documented or tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100