OpenAPITools / OpenAPITools/openapi-generator

[REQ] Is there a way to generate multiple specs in one project?

Open
#5,571 5 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.