springdoc / springdoc-openapi-maven-plugin

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
141 stars 37 forks source link

[Feature request] output in YAML/YML format, and preferably pretty printed (even for the current JSON one) #12

Closed patpatpat123 closed 4 years ago

patpatpat123 commented 4 years ago

Hello,

First of all, a big thanks for this project. This is a feature request, an idea to possibly make this project even more interesting, hope not to trouble.

Currently, this plugin is doing a great job in generating the JSON output.

First questions, can the output be pretty printed instead of the one liner?

Second question, would it be possible to add an option to have the output as (pretty printed) YAML/YML as well?

Thank you for your help.

anthropaedic commented 4 years ago

I can take a look

vietcaominh commented 4 years ago

I think it's good function too.

anthropaedic commented 4 years ago

Created pull request #15 for this issue.

bnasslahsen commented 4 years ago

@anthropaedic,

For pretty print, add the following property as argument: -Dspringdoc.writer-with-default-pretty-printer=true If you want the output in yaml format, just set the two following configuration propeties:

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

Here is a complete setting sample: mvn verify -Dspring.application.admin.enabled=true -Pintegration -Dspringdoc.writer-with-default-pretty-printer=true

<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.3.2.RELEASE</version>
        <executions>
            <execution>
                <id>pre-integration-test</id>
                <goals>
                    <goal>start</goal>
                </goals>
            </execution>
            <execution>
                <id>post-integration-test</id>
                <goals>
                    <goal>stop</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <id>integration-test</id>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <apiDocsUrl>http://localhost:8080/v3/api-docs.yaml
            </apiDocsUrl>
            <outputFileName>openapi.yaml</outputFileName>
        </configuration>
    </plugin>
</plugins>