标签: springdoc-openapi-maven-plugin

如何告诉 springdoc-openapi-maven-plugin 生成 YAML 而不是 JSON?

我正在使用springdoc-maven-openapi-plugin这种方式:

        <plugin>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <apiDocsUrl>http://localhost:9090/v3/api-docs</apiDocsUrl>
                <outputDir>${project.build.directory}/my_open_api_specification/</outputDir>
                <outputFileName>my_open_api_specification.yml</outputFileName>
                <skip>false</skip>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

这会在目标文件夹中生成一个 OpenAPI 文档,其名称带有后缀“ .yml ”,但实际上它是一个 JSON。

我如何告诉插件有效地创建 YAML 格式的文档?

json yaml spring-boot springdoc-openapi-maven-plugin

6
推荐指数
1
解决办法
5591
查看次数

如何使用 springdoc-openapi-maven-plugin 将 POM 构建版本集成到 YAML 生成中?

有没有办法以编程方式将构建版本从 Spring Boot 应用程序的 POM 设置为 springdoc-openapi-maven-plugin 生成的 OpenApi YAML?

我怎样才能实现它?

目前我已经通过这种方式集成了 springdoc-openapi-maven-plugin :

    <plugin>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
            <execution>
                <id>integration-test</id>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <apiDocsUrl>http://localhost:9090/v3/api-docs.yaml</apiDocsUrl>
            <outputFileName>my_open_api_specification.yml</outputFileName>
            <outputDir>${project.build.directory}/my_open_api_specification/</outputDir>
            <skip>false</skip>
        </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

我有一个使用 OpenApi 注释来注释方法的接口:

@Tag(name = "API Operationen")
@RequestMapping
public interface RestApi {
...

    @Bean
    default OpenAPI myOpenApi() {
    
        return new OpenAPI()
            .info(new Info()
                .title("The title")
                .version("1.0")           <-- I want to dynamically set this version with the value coming from  BuildProperties (POM version).
                .description("The description"));
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用 …

pom.xml spring-boot openapi springdoc-openapi-maven-plugin

5
推荐指数
0
解决办法
1245
查看次数