oas-normalize
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -6,3 +6,3 @@ const YAML = require('yamljs'); | ||
// YAML or JSON string to JSON Object | ||
stringToJSON: (string) => { | ||
stringToJSON: string => { | ||
if (typeof string === 'object') { | ||
@@ -17,3 +17,3 @@ return deepClone({}, string); | ||
type: (obj) => { | ||
type: obj => { | ||
if (module.exports.isBuffer(obj)) { | ||
@@ -27,3 +27,4 @@ return 'buffer'; | ||
} | ||
if (obj.match(/\n/)) { // Not sure about this... | ||
if (obj.match(/\n/)) { | ||
// Not sure about this... | ||
return 'string-yaml'; | ||
@@ -40,6 +41,9 @@ } | ||
version: (schema) => schema.swagger || schema.openapi, | ||
version: schema => schema.swagger || schema.openapi, | ||
isBuffer: (obj) => obj != null && obj.constructor != null | ||
&& typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj), | ||
isBuffer: obj => | ||
obj != null && | ||
obj.constructor != null && | ||
typeof obj.constructor.isBuffer === 'function' && | ||
obj.constructor.isBuffer(obj), | ||
}; |
11
oas.js
@@ -14,5 +14,8 @@ const r2 = require('r2'); | ||
this.file = file; | ||
this.opts = deepClone({ | ||
enablePaths: false, | ||
}, opts); | ||
this.opts = deepClone( | ||
{ | ||
enablePaths: false, | ||
}, | ||
opts, | ||
); | ||
this.type = utils.type(this.file); | ||
@@ -31,3 +34,3 @@ | ||
const success = (obj) => { | ||
const success = obj => { | ||
const ret = utils.stringToJSON(obj); | ||
@@ -34,0 +37,0 @@ this.f_load = ret; |
{ | ||
"name": "oas-normalize", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Swagger 2 or OAS 3? YAML or JSON? URL, path, string or object? Who cares! It just works.", | ||
@@ -14,3 +14,5 @@ "main": "oas.js", | ||
"scripts": { | ||
"lint": "eslint -f unix .", | ||
"lint": "eslint .", | ||
"pretest": "npm run lint && npm run prettier", | ||
"prettier": "prettier --list-different --write \"./**/**.{js,jsx}\"", | ||
"test": "jest --coverage" | ||
@@ -28,7 +30,8 @@ }, | ||
"devDependencies": { | ||
"@readme/eslint-config": "^1.5.1", | ||
"eslint": "^6.4.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"jest": "^24.9.0" | ||
"eslint-plugin-jest": "^23.0.4", | ||
"jest": "^24.9.0", | ||
"prettier": "^1.19.1" | ||
} | ||
} |
const swagger = require('swagger-parser'); | ||
module.exports = (el, cb) => { | ||
swagger.validate(el.out.deref, (err) => { | ||
swagger.validate(el.out.deref, err => { | ||
if (err) { | ||
if (err.details && err.details.length) { | ||
return cb({ | ||
errors: [{ | ||
message: err.details[0].message, | ||
path: err.details[0].path, | ||
}], | ||
errors: [ | ||
{ | ||
message: err.details[0].message, | ||
path: err.details[0].path, | ||
}, | ||
], | ||
full: err, | ||
@@ -16,5 +18,7 @@ }); | ||
return cb({ | ||
errors: [{ | ||
message: err.message.replace(/\[object Object\]/g, 'Schema'), | ||
}], | ||
errors: [ | ||
{ | ||
message: err.message.replace(/\[object Object\]/g, 'Schema'), | ||
}, | ||
], | ||
full: err, | ||
@@ -21,0 +25,0 @@ }); |
@@ -7,5 +7,7 @@ const validator = require('swagger2openapi/validate.js'); | ||
return cb({ | ||
errors: [{ | ||
message: err.message, | ||
}], | ||
errors: [ | ||
{ | ||
message: err.message, | ||
}, | ||
], | ||
full: err, | ||
@@ -12,0 +14,0 @@ }); |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
1
9832
5
12
192