Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
] = {};
uniqueKeyObj[allModule.toLowerCase()][allMaster.toLowerCase()] =
allModuleData[allModule][allMaster].uniqueKeys;
}
}
}
// console.log(uniqueKeyObj);
}
}
);
// console.log(specificHeaderObj);
// for(module in modules){
for (var i = 0; i < urls.length; i++) {
SwaggerParser.dereference(urls[i])
.then(function(yamlJSON) {
// console.log(yamlJSON)
let module = yamlJSON["x-module"];
if (module) {
mainObj[module] = yamlJSON.definitions;
} else {
let basePath = [];
basePath = yamlJSON.basePath.split("-")[0].split(""); // "/asset-services" type pattern should be in basepath
let index = basePath.indexOf("/");
if (index > -1) {
basePath.splice(index, 1);
}
mainObj[basePath.join("")] = yamlJSON.definitions;
}
public async init() {
try {
// parse the document
this.document = await SwaggerParser.parse(this.inputDocument);
// validate the document
this.validateDefinition();
// dereference the document into definition
this.definition = await SwaggerParser.dereference(this.document);
} catch (err) {
if (this.strict) {
// in strict-mode, fail hard and re-throw the error
throw err;
} else {
// just emit a warning about the validation errors
console.warn(err);
}
}
// build schemas for all operations
const operations = this.getOperations();
operations.map(this.buildSchemaForOperation.bind(this));
// now that the definition is loaded and dereferenced, we are initalized
this.initalized = true;
let parse = function(yamlPath, module, references, cb) {
mkdirp.sync("./output/" + module);
SwaggerParser.dereference(yamlPath)
.then(function(yamlJSON) {
let basePath = yamlJSON.basePath;
let specifications = {};
let allUiInfo = {};
let errors = {};
for (var i = 0; i < yamlJSON["x-ui-info"].UIInfo.length; i++) {
if(references && references.length) {
if (references.indexOf(yamlJSON["x-ui-info"].UIInfo[i].referencePath) > -1)
allUiInfo[yamlJSON["x-ui-info"].UIInfo[i].referencePath] = yamlJSON["x-ui-info"].UIInfo[i];
} else {
allUiInfo[yamlJSON["x-ui-info"].UIInfo[i].referencePath] = yamlJSON["x-ui-info"].UIInfo[i];
}
}
for (let key in yamlJSON.paths) {
let arr = key.split("/");
arr.splice((arr.length - 1), 1);
let parserPromise = new Promise((resolve) => {
parser.dereference(config.swaggerFile, function(err, api) {
if (err) throw err;
init(api);
resolve();
});
});
parser.parse(dataOrPath, options, function(err, api) {
if (err) {
cb(err);
} else {
var apiData = JSON.parse(JSON.stringify(api));
me.data = api;
if (typeof dataOrPath === 'string') {
var parseFn = parser.dereference(dataOrPath, JSON.parse(JSON.stringify(api)), options);
} else {
parseFn = parser.dereference(JSON.parse(JSON.stringify(api)), options);
}
parseFn.then(function(dereferencedAPI) {
if (options && options.expand) {
me.data = dereferencedAPI;
} else {
me.dereferencedAPI = dereferencedAPI;
}
cb();
})
.catch(cb);
}
});
};
module.exports = async (spec) => {
const bundle = await parser.bundle(spec)
const api = await parser.dereference(cloneDeep(spec))
if (semver.major(api.openapi) !== 3) {
throw new Error('OpenAPI spec must conform to version 3')
}
for (const path of Object.keys(api.paths)) {
const pathItem = api.paths[path]
if (path[0] !== '/') {
throw new Error(`Invalid path "${path}" must start with "/"`)
}
const name = path.slice(1)
if (name && !validators.service(name)) {
if (name.includes('/')) {
parse: async (contract) => {
return SwaggerParser.dereference(
await parser.swaggerFile(contract),
{ baseDir: contract.localContentPath }
);
},
SwaggerParser.parse(self.swagger).then(function (data) {
return SwaggerParser.dereference(data);
}).then(function (data) {
for (var path in data.paths) {
parserUtil = async (data) => {
const parsedRefs = await SwaggerParser.bundle(deepClone(data));
const parsedSwagger = await SwaggerParser.dereference(deepClone(data));
return { parsedSwagger, parsedRefs };
}
onLoad = (url, theme) => {
function successfulParse(parsedApi) {
var swaggerDoc = parsedApi;
swaggerDoc.definitions = requireAllProperties(swaggerDoc.definitions);
return SwaggerParser.dereference(swaggerDoc);
}