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

Newlines (\n) in example filed are output verbatim #39

Open
koppor opened this issue Aug 13, 2017 · 3 comments
Open

Newlines (\n) in example filed are output verbatim #39

koppor opened this issue Aug 13, 2017 · 3 comments

Comments

@koppor
Copy link

koppor commented Aug 13, 2017

When a property of a data object has the field example, \n in this field are output verbatim instead of producing a newline. This makes it hard to output formatted JSON examples.

@nknapp
Copy link
Member

nknapp commented Aug 14, 2017

This seems to be the same as bootprint/bootprint-openapi#77. Examples are raw JSON-objects and not strings. Try including your example directly as object. It should be formatted automatically.

@koppor
Copy link
Author

koppor commented Aug 14, 2017

I'm coming from @ApiModelProperty via swagger-jersey2-jaxrs, so I cannot use JSON-objects instead of strings. At least if I understand @ApiModelProperty correctly.

grafik

@nknapp
Copy link
Member

nknapp commented Aug 17, 2017

I would like to know what the JaxRS-people think about it. Maybe they have another solution for specifying complex examples.
But I reckon, they depend on swagger-ui's ability to derived complex example from the json-schema and the example-values in the leafs.

You may be able to solve your problem with a preprocessor that traverses the swagger-file and calls JSON.parse on all example values.

Writing examples verbatim would require a change in bootprint-json-schema. If you have an idea that works well for JSON-examples (that are real objects), I would accept a PR. Maybe examples can be output verbatim if the type of the schema is not "string", but the example itself is a "string"

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

2 participants