Search code examples
spring-bootmavenmaven-pluginopenapiopenapi-generator

Open Api code generator maven plug in tag details


Below is my open api code gen maven plug in

<plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <version>5.2.0</version>
            <executions>
                <execution>
                    <id>server</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <skipValidateSpec>true</skipValidateSpec>
                        <inputSpec>${project.basedir}/src/main/resources/games.yaml</inputSpec>
                        <generatorName>spring</generatorName>
                        <library>spring-boot</library>
                        <generateSupportingFiles>false</generateSupportingFiles>
                        <output>${project.build.directory}/generated-sources</output>
                        <apiPackage>com.tintin.api</apiPackage>
                        <modelPackage>com.tintin.model</modelPackage>
                        <configOptions>
                            <supportingFilesToGenrate>ApiUtil.java</supportingFilesToGenrate>
                            <interfaceOnly>true</interfaceOnly>
                            <delegatePattern>true</delegatePattern>
                            <dateLibrary>java8</dateLibrary>
                            <skipDefaultInterface>true</skipDefaultInterface>
                        </configOptions>
                    </configuration>
                </execution>
            </executions>
        </plugin>

What is the difference between configuration and configOption tags. And which options to place inside whic tags?


Solution

  • The <configuration> elements aims to provide configuration for your plugin i.e. the org.openapitools:openapi-generator-maven-plugin:x.y.z in your case. The <configuration> element is a standard plugin tag that aims to encapsulate a plugin configuration as a whole. It is a general element that can host any sub-elements of any shape and is common to all plugins.

    The <configOptions> on the other hand is a plugin, i.e. org.openapitools:openapi-generator-maven-plugin:x.y.z, specific element that declares configuration properties specific to the plugin it self. This is a non-standard tag and has to be mapped to a particular field in the plugin XXXMojo.java type. Here you can see the mapping:

    public class CodeGenMojo extends AbstractMojo {
    
        // other properties
        
        /**
         * A map of language-specific parameters as passed with the -c option to the command line
         */
        @Parameter(name = "configOptions")
        private Map<?, ?> configOptions;
    
        // ...
    }