springopenapi-generatoropenapi-generator-maven-plugin

How to generate only @HttpExchange and DTOs from OpenAPI spec?


I have an OpenAPI spec file, but I couldn't get the openapi-generator-maven-plugin generate only the Spring @HttpExchange interfaces and DTOs (model classes).

The closest I could get was using the spring generator with <library>spring-http-interface</library> but it generates some stuff I don't want about client configuration and service wrapping.

The problems I have with this generated configuration is that it makes wrong assumptions on the REST client I want to use (I'm writing a servlet and intend to use RestClient, not WebClient). Plus I want to configure that REST client bean myself (tune authorization and proxy settings).

What I used so far:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <!-- RELEASE_VERSION -->
    <version>7.2.0</version>
    <!-- /RELEASE_VERSION -->
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/../spec.json</inputSpec>
                <generatorName>spring</generatorName>
                <apiPackage>com.my.service.api</apiPackage>
                <modelPackage>com.my.service.model</modelPackage>
                <configOptions>
                   <library>spring-http-interface</library>
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

Did I miss a config option?

Is there another generator I can use to produce just the @HttpExchange interfaces and DTOs?


Solution

  • If it is not too late, you can only generate interfaces with

    <configOptions>
        ...
        <interfaceOnly>true</interfaceOnly>
    </configOptions>