swagger2openapi
Advanced tools
Comparing version 3.2.13 to 3.2.14
@@ -16,2 +16,3 @@ // @ts-check | ||
const clone = require('reftools/lib/clone.js').clone; | ||
const cclone = require('reftools/lib/clone.js').circularClone; | ||
const recurse = require('reftools/lib/recurse.js').recurse; | ||
@@ -479,3 +480,3 @@ const resolver = require('oas-resolver'); | ||
} | ||
if (param.description == null) delete param.description; | ||
if (param.description === null) delete param.description; | ||
@@ -1233,2 +1234,3 @@ let oldCollectionFormat = param.collectionFormat; | ||
options.rewriteRefs = true; // avoids stack explosions | ||
options.preserveMiro = true; | ||
options.promise = {}; | ||
@@ -1239,3 +1241,3 @@ options.promise.resolve = resolve; | ||
if (swagger.openapi && (typeof swagger.openapi === 'string') && swagger.openapi.startsWith('3.')) { | ||
options.openapi = clone(swagger); | ||
options.openapi = cclone(swagger); | ||
fixInfo(options.openapi, options, reject); | ||
@@ -1282,3 +1284,3 @@ fixPaths(options.openapi, options, reject); | ||
// we want the new and existing properties to appear in a sensible order. Not guaranteed | ||
openapi = Object.assign(openapi, clone(swagger)); | ||
openapi = Object.assign(openapi, cclone(swagger)); | ||
delete openapi.swagger; | ||
@@ -1285,0 +1287,0 @@ |
@@ -15,3 +15,3 @@ #!/usr/bin/env node | ||
const common = require('oas-kit-common'); | ||
const clone = require('reftools/lib/clone.js').clone; | ||
const clone = require('reftools/lib/clone.js').circularClone; | ||
@@ -93,2 +93,3 @@ const swagger2openapi = require('./index.js'); | ||
options.fatal = true; | ||
if (options.verbose) Error.stackTraceLimit = Infinity; | ||
@@ -116,3 +117,3 @@ function finalise(err, options) { | ||
} | ||
options.valid = !!options.expectFailure; | ||
options.valid = (!!options.expectFailure || options.allowFailure); | ||
} | ||
@@ -164,10 +165,15 @@ if (options.warnings) { | ||
} | ||
let resultStr = JSON.stringify(result); | ||
let resultStr = yaml.dump(result); | ||
if (typeof result !== 'boolean') try { | ||
if (!options.yaml) { | ||
resultStr = yaml.safeDump(result, { lineWidth: -1 }); // should be representable safely in yaml | ||
let resultStr2 = yaml.safeDump(result, { lineWidth: -1, noRefs: true }); | ||
should(resultStr).not.be.exactly('{}','Result should not be empty'); | ||
should(resultStr).equal(resultStr2,'Result should have no object identity ref_s'); | ||
try { | ||
resultStr = yaml.safeDump(result, { lineWidth: -1 }); // should be representable safely in yaml | ||
let resultStr2 = yaml.safeDump(result, { lineWidth: -1, noRefs: true }); | ||
should(resultStr).not.be.exactly('{}','Result should not be empty'); | ||
should(resultStr).equal(resultStr2,'Result should have no object identity ref_s'); | ||
} | ||
catch (ex) { | ||
should.fail(false,true,'Result cannot be represented safely in YAML'); | ||
} | ||
} | ||
@@ -179,5 +185,5 @@ | ||
console.log(common.colour.normal + options.file); | ||
console.log(common.colour.red + options.context.pop() + '\n' + ex.message); | ||
console.warn(common.colour.red + (options.context.length ? options.context.pop() : 'No context')+ '\n' + ex.message); | ||
if (ex.stack && ex.name !== 'AssertionError' && ex.name !== 'CLIError') { | ||
console.log(ex.stack); | ||
console.warn(ex.stack); | ||
} | ||
@@ -234,7 +240,17 @@ options.valid = !options.expectFailure; | ||
options.source = file; | ||
options.expectFailure = false; | ||
options.allowFailure = false; | ||
if ((options.source.indexOf('!')>=0) && (options.source.indexOf('swagger.')>=0)) { | ||
expectFailure = true; | ||
options.expectFailure = true; | ||
options.allowFailure = true; | ||
} | ||
if ((options.source.indexOf('!')>=0) && (options.source.indexOf('openapi.')>=0)) { | ||
expectFailure = true; | ||
options.expectFailure = false; // because some things are corrected | ||
options.allowFailure = true; | ||
} | ||
if (file.startsWith('http')) { | ||
@@ -265,2 +281,3 @@ swagger2openapi.convertUrl(file, clone(options)) | ||
console.warn(common.colour.red+ex,common.colour.normal); | ||
console.warn(ex.stack); | ||
if (expectFailure) { | ||
@@ -267,0 +284,0 @@ warnings.push('Converter failed ' + options.source); |
{ | ||
"name": "swagger2openapi", | ||
"version": "3.2.13", | ||
"version": "3.2.14", | ||
"description": "Convert Swagger 2.0 definitions to OpenApi 3.0 and validate", | ||
@@ -34,11 +34,11 @@ "main": "index.js", | ||
"call-me-maybe": "^1.0.1", | ||
"js-yaml": "^3.6.1", | ||
"node-fetch": "^2.0.0", | ||
"js-yaml": "^3.12.0", | ||
"node-fetch": "^2.3.0", | ||
"node-readfiles": "^0.2.0", | ||
"oas-kit-common": "^1.0.3", | ||
"oas-resolver": "^1.0.11", | ||
"oas-kit-common": "^1.0.4", | ||
"oas-resolver": "^1.0.12", | ||
"oas-schema-walker": "^1.1.0", | ||
"oas-validator": "^1.1.12", | ||
"reftools": "^1.0.2", | ||
"yargs": "^11.0.0" | ||
"oas-validator": "^1.1.13", | ||
"reftools": "^1.0.3", | ||
"yargs": "^12.0.2" | ||
}, | ||
@@ -58,8 +58,3 @@ "keywords": [ | ||
], | ||
"devDependencies": { | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.18.2", | ||
"mocha": "^5.0.0" | ||
}, | ||
"gitHead": "e1f081373030c7b331cbd4ebd1042c19b2784a18" | ||
"gitHead": "4862e159745d6ca06044bc3ebabe57a2ad8b7152" | ||
} |
@@ -25,2 +25,5 @@ #!/usr/bin/env node | ||
.describe('encoding', 'encoding for input/output files') | ||
.boolean('fatal') | ||
.alias('f','fatal') | ||
.describe('fatal','make resolution errors fatal') | ||
.help('help') | ||
@@ -74,7 +77,13 @@ .alias('h', 'help') | ||
let s; | ||
if (options.yaml) { | ||
s = options.debug ? yaml.dump(options.openapi) : yaml.safeDump(options.openapi); | ||
try { | ||
if (options.yaml) { | ||
s = options.debug ? yaml.dump(options.openapi) : yaml.safeDump(options.openapi, {noRefs:true}); | ||
} | ||
else { | ||
s = JSON.stringify(options.openapi, null, options.indent||4); | ||
} | ||
} | ||
else { | ||
s = JSON.stringify(options.openapi, null, options.indent||4); | ||
catch (ex) { | ||
console.warn('The result cannot be represented safely in the chosen output format'); | ||
s = '{}'; | ||
} | ||
@@ -81,0 +90,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93640
0
2107
- Removedcamelcase@4.1.0(transitive)
- Removedfind-up@2.1.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyargs@11.1.1(transitive)
- Removedyargs-parser@9.0.2(transitive)
Updatedjs-yaml@^3.12.0
Updatednode-fetch@^2.3.0
Updatedoas-kit-common@^1.0.4
Updatedoas-resolver@^1.0.12
Updatedoas-validator@^1.1.13
Updatedreftools@^1.0.3
Updatedyargs@^12.0.2