5

I am using the springdoc-maven-openapi-plugin this way:

        <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>

This results in an OpenAPI doc in the target folder with a name having a suffix ".yml" but in fact it is a JSON.

How can I tell the plugin to effectively create the doc in YAML format?

du-it
  • 2,561
  • 8
  • 42
  • 80

2 Answers2

4

http://localhost:9090/v3/api-docs is the default api-url, which generates JSON. To create YAML just use http://localhost:9090/v3/api-docs.YAML

Thilo Schwarz
  • 640
  • 5
  • 24
3

The question is about compile-time generation.

For compile it will be like:

<configuration>
    <apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</apiDocsUrl>
    <outputFileName>openapi.yaml</outputFileName>
    <skip>false</skip>
</configuration>

apiDocsUrl should ends with .yaml otherwise it generates JSON in yaml file

Expect by running:

./mvnw springdoc-openapi:generate

In ./target/openapi.yaml the spec in yaml format

See https://github.com/springdoc/springdoc-openapi-maven-plugin/issues/12 for more

Artem Ptushkin
  • 1,151
  • 9
  • 17