OpenAPITools / OpenAPITools/openapi-generator

How to use a custom generator with gradle plugin?

Open
#6,190 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I am new to gradle & openAPI. I generated a custom openapi generator and put it in a multi project setup. How do I use this generator in my task?

openapi-generator version

Latest

Command line used for generation

I have a two projects, api and my-generator. I have a gradle task in api as below:

dependencies {
    ....
    implementation(project(":my-generator"))
}

tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateApiControllers") {
    generatorName.value("my-generator")

It throws ERROR: Unable to load class 'my-generator'.

How do I make openapi-generator recognise my-generator?

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 and the multi-project dependency declaration shown in the issue. Trace how generatorName.value("my-generator") resolves custom generators and how the my-generator project is exposed to that task. Done means the generateApiControllers task recognizes the custom generator and runs without the class-loading error.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system, tooling
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.