我如何仅生成API接口?

时间:2019-04-16 13:39:32

标签: angular typescript openapi openapi-generator

我试图仅使用OpenApi及其maven插件 openapi-generator-maven-plugin 生成接口,但是它也生成不需要/不需要的完整服务。< / p>

现在我已经找到了 withInterfaces 属性,但是当设置为true时,它会生成API服务。因此,它可以生成我想要的内容,也可以生成我不需要的服务。

这是我的pom配置:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>3.3.4</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${openAPIContractsDirectory}/swagger.json</inputSpec>
                <generatorName>typescript-angular</generatorName>
                <output>${openAPIOutputDirectory}</output>
                <configOptions>
                    <ngVersion>7.2.11</ngVersion>
                    <withInterfaces>true</withInterfaces>
                </configOptions>
                <generateApiTests>false</generateApiTests>
                <generateApiDocumentation>false</generateApiDocumentation>
                <generateModelTests>false</generateModelTests>
                <generateModelDocumentation>false</generateModelDocumentation>
                <supportingFilesToGenerate>variables.ts,configuration.ts,encoder.ts</supportingFilesToGenerate>
            </configuration>
        </execution>
    </executions>
</plugin>

我想要的是模型,pom中描述的一些支持文件以及 API接口(不是完整的服务)。

有人会知道如何做吗?

1 个答案:

答案 0 :(得分:0)

将此内部部分添加到插件配置中

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