Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty print JSON output #541

Closed
mchambaud opened this issue Oct 26, 2015 · 4 comments
Closed

Pretty print JSON output #541

mchambaud opened this issue Oct 26, 2015 · 4 comments

Comments

@mchambaud
Copy link

Is it possible to output pretty JSON? I found this but I think it's not valid with Swashbuckle

swagger-api/swagger-core#810

@gordey4doronin
Copy link
Contributor

Hi,

Swashbuckle doesn't useswagger-core to generate the JSON documentation (correct me if I'm wrong?).
So yes, swagger.pretty.print has no effect.

However, as I see from the source code - it is possible to prettify Swashbuckle JSON output simply configuring JsonMediaTypeFormatter to use Formatting.Indented here https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Application/SwaggerDocsHandler.cs#L54-L58

SerializerSettings = new JsonSerializerSettings
{
    NullValueHandling = NullValueHandling.Ignore,
    Formatting = Formatting.Indented,
    Converters = new[] { new VendorExtensionsConverter() }
}

But since this prettifying should be configurable (turn off/on), one should extend SwaggerDocsConfig with some kind of a flag bool _prettifyJsonOutput or smth like this.

Why I know the answer to your question?
Because I would to have pretty output too and also made some investigation :)

Les't wait for the answer from @domaindrivendev and maybe he, you or me will add this feature if approved.

@gordey4doronin
Copy link
Contributor

@mchambaud just pushed the PR #577

@mchambaud
Copy link
Author

@GDoronin Thanks mate, much appreciated!

@domaindrivendev
Copy link
Owner

See 5.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants