Skip to content

Commit a649310

Browse files
committed
chore: add option to format to backward compatibility
1 parent b8935fe commit a649310

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/openapi-sampler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const defaults = {
1010
};
1111

1212
function convertJsonToXml(obj, schema) {
13-
if (!obj || typeof obj !== 'object') {
13+
if (!obj) {
1414
throw new Error('Unknown format output for building XML.');
1515
}
1616
if (Array.isArray(obj) || Object.keys(obj).length > 1) {
@@ -29,7 +29,7 @@ export function sample(schema, options, spec) {
2929
let opts = Object.assign({}, defaults, options);
3030
clearCache();
3131
let result = traverse(schema, opts, spec).value;
32-
if (opts.format === 'xml') {
32+
if (opts?.format === 'xml') {
3333
return convertJsonToXml(result, schema);
3434
}
3535
return result;

0 commit comments

Comments
 (0)