Unable To Provide Json Example
Hi folks,
I've been working on an issue over at a repo using this project and have come across a shortcoming whereby we can't provide a preformatted JSON example.
We're trying to supply a preformatted example such as:
"error": {
"code": "EX0100",
"reference": "https://reference.url",
"message": "Authentication must be provided"
}
However, using an OpenApiString we get the following output:
"example": "{\r\n \"error\": {\r\n \"code\": \"EX0100\",\r\n \"reference\": "https://reference.url\",\r\n \"message\": \"Authentication must be provided\"\r\n }\r\n}"
As far as I can tell there isn't currently a way to define a string that is already preformatted and unless I'm missing something obvious, I think this library should provide a means to do so. I've proposed a class in the linked repo OpenApiRawString as a stopgap and am happy to submit a similar pull request here if it would be of use?
Cheers
I think this could work. How would you feel about calling it OpenAPIJsonLiteral or OpenAPIJsonString?
I don't have any objections to the name change. In theory, it should only be JSON data that is affected, other formats would expect to be enclosed in quotes.
I think OpenAPIJsonLiteral sounds like a better fit. If you're in agreement I can go ahead and submit that amended pull request?
@WarpSpideR Sounds good to me.
@WarpSpideR did you get anywhere with this? It would be great to see this change make it in 🙂