Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
Feat: support example body undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
joolfe committed Nov 5, 2022
1 parent e1d0724 commit 2e7b31d
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 361 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ function parseExamples (bodies, language) {
function safeSampleParse (body, name, language) {
if (language === 'json') {
const errors = []
const parsedBody = jsonc.parse((body === null || body.trim().length === 0) ? '{}' : body, errors)
const parsedBody = jsonc.parse((body == null || body.trim().length === 0) ? '{}' : body, errors)
if (errors.length > 0) {
throw new Error('Error parsing response example "' + name + '"')
}
Expand Down
Loading

0 comments on commit 2e7b31d

Please sign in to comment.