OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Unable To Provide Json Example

Open WarpSpideR opened this issue 6 years ago • 5 comments

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

WarpSpideR avatar Jun 24 '19 08:06 WarpSpideR

I think this could work. How would you feel about calling it OpenAPIJsonLiteral or OpenAPIJsonString?

darrelmiller avatar Aug 23 '19 03:08 darrelmiller

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 avatar Aug 23 '19 14:08 WarpSpideR

@WarpSpideR Sounds good to me.

darrelmiller avatar Sep 02 '19 21:09 darrelmiller

@WarpSpideR did you get anywhere with this? It would be great to see this change make it in 🙂

flcdrg avatar Jun 16 '21 00:06 flcdrg