OpenAPITools / OpenAPITools/openapi-generator

[REQ] Just can't make this work

Open
#10,227 4 comments 2 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

I am so sorry to open up an issue because of this but idk why I am simply not getting how I am supposed to use the generator.

Note: Just found https://github.com/OpenAPITools/openapi-generator/pull/9059, https://github.com/OpenAPITools/openapi-generator/issues/8591 (might be related)

What I intend to do is have different tasks in order to generate clients in different languages.

So for example, I'd like to specify one task for Angular and another for Java, something like this:

openApiGenerate {
    inputSpec swaggerFilePath
}

task buildTypeScriptAngular(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = "typescript-angular"
    outputDir = "$apiClientOutputDir/angular"
    configOptions = [
            npmName   : "$name-rest-client",
            npmVersion: '0.0.0',
            ngVersion : '11.0.6'
    ]
}

task buildJava(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
    generatorName = "java"
    outputDir = "$apiClientOutputDir/java"
}

However, I'm struggling with openApiGenrate from the start. If I am writing:

openApiGenerate {
    inputSpec swaggerFilePath
}

I'd get

A problem occurred evaluating root project 'server-client-template'.
> No signature of method: build_8cj7fyrw9t67hxobm8609uql7.openApiGenerate() is applicable for argument types: (build_8cj7fyrw9t67hxobm8609uql7$_run_closure7) values: [build_8cj7fyrw9t67hxobm8609uql7$_run_closure7@5c2cd655]

If I am using the assignment operator

openApiGenerate {
    inputSpec = swaggerFilePath
}

I'd get the following error

A problem was found with the configuration of task ':openApiGenerate' (type 'GenerateTask').
  - In plugin 'org.openapi.generator' type 'org.openapitools.generator.gradle.plugin.tasks.GenerateTask' property 'input' annotated with @Internal should not be also annotated with @Input.

I cannot find a simple example on how to do this properly. Can somebody please tell me how this works - it really gets frustrating.

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 GenerateTask configuration and compare the two error cases with pull request 9059 and issue 8591. Document a minimal working example for one generation task and separate Angular and Java tasks; it is done when the examples configure without the reported Gradle errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, java, openapi
Domain
api, build-system, tooling
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.