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

Auto JSON format openapi.json #42

Closed pavleprica closed 1 year ago

pavleprica commented 2 years ago

Hey team,

While using this plugin, I thought it might be cool to have JSON auto-formatting.

When generating the openapi.json file it creates a big one-liner. I know that people don't sit around and read the schema generated, but it comes in handy when you want to test quickly if your schema is generated the way you want it to be.

This might impact in a way that new dependencies are added to not write the whole formatted, what are your thoughts? :)

capsuleman commented 1 year ago

On my project, yaml documentation is generated, it is much more human-readable :-)

pavleprica commented 1 year ago

That's a fair point indeed. 😄 Though I guess it's also a matter of habit. 😄

fabricio-entringer commented 1 year ago

On my project, yaml documentation is generated, it is much more human-readable :-)

Hello @capsuleman , how can you set it to generate yaml instead of json format? It didn't work for me! Could you please give me a help with this case?

apigitlabs commented 1 year ago

@fabricio-entringer you can add openapi.yaml in section to get .yaml instead of .json. However, the yaml is still a one-line file in my case

bnasslahsen commented 1 year ago

This feature is already in place #12 To format the json correctly use the springdoc-openapi property as argument of your maven goal: -Dspringdoc.writer-with-default-pretty-printer=true