Open prabhuaxm opened 1 year ago
I think it will probably look like this:
<additionalProperties>serviceName=core-service</additionalProperties>
@chibat Thanks for the reply! I tried using this but was not able to access the value in the mustache code by doing private static final String serviceName = "{{serviceName}}";
or private static final String serviceName = "{{additionalProperties.serviceName}}";
Can you tell me how to access an additional property?
I believe the following is correct
private static final String serviceName = "{{serviceName}}";
@chibat I tried both the ways but didn't work. Can you me point to any documentation where how to use additionalProperties
is listed? The table in README does not provide much info
@prabhupant I can confirm that following works just fine with openapi generator 7.2.0. You can pass multiple parameter with comma as shown below. Just make sure there is no space or double quotes. It should work just fine.
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.2.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.baseDir}/src/main/resources/openapi.json</inputSpec>
<generatorName>java</generatorName>
<library>resttemplate</library>
<additionalProperties>serviceName=core-service,otherParam=value1</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
I stumbled over this as well. In the docs it says
You can also have multiple occurrences of this option
But when I define it multiple times, only the last entry is used. When I join them with a comma like Vishal posted above it's working.
Context
I could not find anything in the docs (here and here) related to using user-defined properties in the mustache template, so opening the issue here.
Description
I am trying to modify the mustache template for webclient in Java. Basic stuff works, like making the ApiClient a Spring component, adding methods, etc. But I want to pass service name in the template. For that, I was looking at passing the service name through
pom.xml
but there is no such variable for this. So I decided to useadditionalProperties
but could not find a way that worked.I created a variable like this
but the mustache template for ApiClient does not pick up the
serviceName
property.Here is how I am using the
serviceName
property in the mustache templateI have tried the following combinations when
additionalProperties
is underconfiguration
tag and also placed it underconfigOptions
just to get it workin -This is currently blocking me. As a workaround, I decided to store the service name in
packageName
tag but I worry if in some upcoming version this is deprecated, then our changes will start to break, or some other use-case forpackageName
comes up then we might have to scrape all the changes.Could you please tell how to use user-defined properties in the mustache template?