1

我正在从 swagger (Open API 2) 迁移到 springdoc (Open API 3),但今天在某些情况下,我使用 swagger-codegen-maven-plugin 从 yaml 生成代码(用于客户端和提供者),遵循 Contract First 策略. 下面是配置示例:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.4.9</version>
    <executions>
        <execution>
            <id>generate-provider-v1</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <inputSpec>${project.basedir}/src/main/resources/swagger/my-api.yaml</inputSpec>
        <output>${project.build.directory}/generated-sources/swagger</output>
        <language>spring</language>
        <library>spring-boot</library>
        <modelPackage>br.com.sample.representation</modelPackage>
        <apiPackage>br.com.sample.adapter.controller.v1</apiPackage>
        <generateSupportingFiles>true</generateSupportingFiles>
        <configOptions>
            <interfaceOnly>true</interfaceOnly>
            <delegatePattern>true</delegatePattern>
            <dateLibrary>java8</dateLibrary>
        </configOptions>
        <modelNameSuffix>Representation</modelNameSuffix>
        <generateSupportingFiles>false</generateSupportingFiles>
    </configuration>
</plugin>

是否有任何等效选项可以使用 springdoc-openapi-maven-plugin 生成代码?

4

1 回答 1

3

如文档中所述:

springdoc-openapi-maven-plugin 的目的是在构建期间生成 json 和 yaml OpenAPI 描述。该插件在集成测试阶段工作,并生成 OpenAPI 描述。

您可以查看用于从规范生成代码的 openapi-generator-maven-plugin:

于 2020-05-11T18:25:54.573 回答