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

Add JSON formatting #42 #43

Closed pavleprica closed 1 year ago

pavleprica commented 2 years ago

I took the liberty of adding the PR for the issue. It adds a lightweight dependency of org.json. Used to parse the string in case we want to write to a .json file and then indent it properly.

Please do share your thoughts.

Related to: https://github.com/springdoc/springdoc-openapi-maven-plugin/issues/42

pavleprica commented 1 year ago

Hey team, @bnasslahsen @gklp @DennisHalmstad any chance for a review and opinion? :)

apigitlabs commented 1 year ago

vote for this one

pavleprica commented 1 year ago

@gklp @bnasslahsen @adrien-ben Any chance to check it out? :)

pavleprica commented 1 year ago

@DennisHalmstad cool! Thanks for the comment and approve! Do you perhaps know who can we contact with write access to merge it?

adrien-ben commented 1 year ago

Hi, looks good to me but I'm not a member of the team, sorry :/

bnasslahsen commented 1 year ago

@pavleprica,

There is no need for extra dependency. 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

pavleprica commented 1 year ago

@bnasslahsen thank you for reaching out! I've tested it locally and the pretty printer doesn't work. Frankly, I can't even find it in the code using the flag.

Could you perhaps provide an example of the command?

bnasslahsen commented 1 year ago

see the https://springdoc.org/#properties and the code reference https://github.com/springdoc/springdoc-openapi/blob/3745c32cdd742cf3e7e1ddb3f393eef238d69ba0/springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocConfigProperties.java#L132

The sample command was in the referenced issue https://github.com/springdoc/springdoc-openapi-maven-plugin/issues/12#issuecomment-670402033 This is a sample command again:

mvn verify -Dspringdoc.writer-with-default-pretty-printer=true

And you are still unable to make it work, as described in the contribution guidelines

Make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.

pavleprica commented 1 year ago

Thanks for the references, I'll see to follow through in more depth and if needed to provide you with a minimal reproducible example. :)