OpenAPITools / OpenAPITools/openapi-generator

[REQ] [DOCUMENTATION] outputDir is required when generating multiple clients (Java, Gradle)

Open
#8,662 0 comments 0 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

The problem

I was adding a second Java client to a gradle project with 1 client. The existing gradle config was like this (for anonymity's sake, I'm building hello world as a service).

openApiGenerate {
    validateSpec = true
    inputSpec = "$rootDir/openapi/hello_openapi.yaml"
    generatorName = "java"
    library = "resttemplate"
    modelPackage = "com.hello_world_client.generated.model"
    apiPackage = "com.hello_world_client.generated.api"
    invokerPackage = "com.hello_world_client.generated"
    configOptions = [
            dateLibrary: "java8"
    ]
}

Changing it to this results in a very cryptic error about a './docs/HelloTemplate.md' not being found.

task buildHelloClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
   // identical config
}

The error is resolved by adding outputDir to the config (which I only tried because it's used in the examples). I didn't lose too much time, but still annoying.

Describe the solution you'd like

I'd like the section on generating multiple sources to explicitly state that outputDir is required.

Describe alternatives you've considered

I proposed the lowest effort solution since this isn't a big deal really, but to solve the issue itself, some alternatives:

  • the generator be improved that any configuration in a openApiGenerate block is works with a task that extends GenerateTask and vice versa
  • the generator may try to detect this situation and throw a clear exception.

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 documentation section and examples covering generation of multiple sources and the Gradle GenerateTask. Document that outputDir is required when generating multiple clients, then verify the example configuration and wording against the reported Gradle behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.