swagger2openapi
Advanced tools
Comparing version 2.3.3 to 2.5.0
@@ -78,2 +78,7 @@ 'use strict'; | ||
base.pop(); // drop the actual filename | ||
let fragment = ''; | ||
let fnComponents = pointer.split('#'); | ||
if (fnComponents.length>1) { | ||
fragment = '#'+fnComponents[1]; | ||
} | ||
base = base.join('/'); | ||
@@ -89,2 +94,5 @@ if (options.verbose) console.log((u.protocol ? 'GET ' : 'file://') + base+'/'+pointer); | ||
data = yaml.safeLoad(data,{json:true}); | ||
if (fragment) { | ||
data = resolveInternal(data,fragment); | ||
} | ||
} | ||
@@ -91,0 +99,0 @@ catch (ex) {} |
20
index.js
@@ -200,6 +200,7 @@ // @ts-check | ||
function fixParamRef(param) { | ||
if (param.$ref.startsWith('#/parameters/')) { | ||
param.$ref = '#/components/parameters/'+common.sanitise(param.$ref.replace('#/parameters/','')); | ||
if (param.$ref.indexOf('#/parameters/')>=0) { | ||
let refComponents = param.$ref.split('#/parameters/'); | ||
param.$ref = refComponents[0]+'#/components/parameters/'+common.sanitise(refComponents[1]); | ||
} | ||
if (param.$ref.startsWith('#/definitions/')) { | ||
if (param.$ref.indexOf('#/definitions/')>=0) { | ||
throwError('Definition used as parameter',options); | ||
@@ -226,3 +227,3 @@ } | ||
if ((!target) || (target["x-s2o-delete"])) { | ||
if (((!target) || (target["x-s2o-delete"])) && param.$ref.startsWith('#/')) { | ||
// if it's gone, chances are it's a requestBody component now unless spec was broken | ||
@@ -237,5 +238,10 @@ param["x-s2o-delete"] = true; | ||
if (rbody) { | ||
var ref = param.$ref; | ||
param = common.resolveInternal(openapi,param.$ref); | ||
if (!param) throwError('Could not resolve reference '+ref,options); | ||
let ref = param.$ref; | ||
let newParam = common.resolveInternal(openapi,param.$ref); | ||
if (!newParam && ref.startsWith('#/')) { | ||
throwError('Could not resolve reference '+ref,options); | ||
} | ||
else { | ||
if (newParam) param = newParam; // preserve reference | ||
} | ||
} | ||
@@ -242,0 +248,0 @@ } |
{ | ||
"name": "swagger2openapi", | ||
"version": "2.3.3", | ||
"version": "2.5.0", | ||
"description": "Convert Swagger 2.0 definitions to OpenApi 3.0", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,2 +51,3 @@ #!/usr/bin/env node | ||
if (err) { | ||
delete err.options; | ||
console.log(util.inspect(err)); | ||
@@ -53,0 +54,0 @@ return process.exitCode = 1; |
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
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
190654
5053