RapiDoc icon indicating copy to clipboard operation
RapiDoc copied to clipboard

Unable to parse JSON examples response when it contains specific values

Open Polders opened this issue 3 years ago • 1 comments

Hello,

We discovered that while many of our response examples are correctly parsed and displayed in tree form with syntax highlighting, some of them default to text.

An example like this one

{ "textWithSingleQuote": "let's say this is my text" }

or this one

{ "isoDate": "2022-08-08T00:00:00.000Z" }

will both default to text despite being valid JSON (the second one is especially important to us because we have a lot of dates)

After reading your sources, I believe the cause to be a line in schema-utils.js, in generateExample() where there is an attempt to "fix" the JSON string by replacing values according to two regex that happen to match the text in my examples above.

It seems like this is trying to fix invalid JSON without proper double quotes into correct JSON, but it breaks valid JSON in the attempt. Also weirdly this doesn't happen when using the example attribute instead of the examples plural.

Other than that Rapidoc rocks, thank you for this awesome piece of software and have a nice day.

Polders avatar Aug 08 '22 17:08 Polders

thanks for reporting, will take a look at it

mrin9 avatar Aug 11 '22 13:08 mrin9