OpenAPITools / OpenAPITools/openapi-generator

Unable to pass custom properties to custom generator

Open
#22,217 2 comments 0 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

I'm developing a custom OpenAPI Generator and would like to execute specific logic based on custom configuration properties defined in the Maven plugin configuration.

Here’s an example of my plugin configuration in the pom.xml:

<plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${openapi-maven-plugin-version}</version>
        <executions>
          <execution>
            <id>generate</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration combine.self="append">
              <inputSpec>${swagger.desc.dir}/${swagger.desc.filename}</inputSpec>
              <generatorName>${swagger-generator}</generatorName>
              <generateApis>${generate-apis}</generateApis>
              <additionalProperties>
                <customProperty>true</customProperty>
              </additionalProperties>
            </configuration>
          </execution>
        </executions>
      </plugin>

In my custom generator class (Java), I want to retrieve and use this property for example :
Boolean isCustom = (Boolean) additionalProperties.get("customProperty");
However, when I attempt to access it, it returns null.
Is there a way to declare and retrieve custom properties ?

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 Maven plugin's handling of the additionalProperties configuration and trace how those values reach the custom generator class. Reproduce the provided pom.xml configuration, verify whether customProperty is forwarded and typed as expected, and add or update a focused regression test showing that the property is available to the generator.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.