Socket
Socket
Sign inDemoInstall

swagger2openapi

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger2openapi - npm Package Compare versions

Comparing version 3.2.13 to 3.2.14

8

index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc