从 Springdoc 中的规范生成代码 Open API 3

Generate code from spec in Springdoc Open API 3

我正在从 swagger(打开 API 2)转向 springdoc(打开 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 生成代码有等效的选项吗?

如文档中所述:

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

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