OpenAPITools / OpenAPITools/openapi-generator
Unable to pass custom properties to custom generator
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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