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

时间:2020-05-08 21:11:42

标签: springdoc

我正在从swagger(Open API 2)迁移到springdoc(Open API 3),但是今天在某些情况下,我会使用swagger-codegen-maven-plugin从yaml生成代码(针对客户端和提供者),合同优先战略。下面是配置示例:

<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生成代码?

1 个答案:

答案 0 :(得分:0)

如文档中所述:

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

您可以查看通过规范生成代码的openapi-generator-maven-plugin:

相关问题