Skip to content

[REQ] Openapi-generator-maven-plugin using configurationFile only #22255

@jpfinne

Description

@jpfinne

Is your feature request related to a problem? Please describe.

I want to make generatorName and inputSpec optional in the mojo if they are defined in a configuration file.
This is to simplify my CI pipelines.

The goal is to have most configuration done in yaml instead of in xml.

Describe the solution you'd like

Ability to use generatorName and inputSpec defined in configurationFile if not present in <configuration> in the pom.xml.
Optionally skip the generation if the configurationFile does not exist.

For example using a parent pom:

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.openapi.generator</groupId>
    <artifactId>configuration-file-demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>server-api</module>
        <module>client-api</module>
        <module>typescript-angular</module>
        <module>service</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <configuration>
                    <configurationFile>${project.basedir}/config.yaml</configurationFile>
                    <skipIfConfigurationFileMissing>true</skipIfConfigurationFileMissing>
                </configuration>
                <executions>
                    <execution>
                        <id>executionId</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Each module would contain a config.yaml that triggers the generation.
No other configuration would be needed

For example in server-api folder:

pom.xml

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
      <groupId>org.openapi.generator</groupId>
      <artifactId>configuration-file-demo</artifactId>
      <version>1.0-SNAPSHOT</version>
    </parent>
  <artifactId>server-api</artifactId>
  <dependencies>
       ...
  </dependencies>
</project>

config.yaml

inputSpec: petstore-on-classpath.yaml
generatorName: spring

Describe alternatives you've considered

Some configuration in xml, some configuration in yaml

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions