Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
header.includes = options.includes;
header.search = options.search;
header.highlight_theme = options.theme;
if (typeof templates === 'undefined') {
templates = dot.process({ path: path.join(__dirname, '..', 'templates', 'semoasa') });
}
if (options.user_templates) {
templates = Object.assign(templates, dot.process({ path: options.user_templates }));
}
let data = {};
if (options.verbose) console.log('starting deref',api.info.title);
data.api = dereference(api,api,{verbose:options.verbose,$ref:'x-widdershins-oldRef'});
if (options.verbose) console.log('finished deref');
data.options = options;
data.header = header;
data.templates = templates;
data.translations = {};
templates.translations(data);
data.oas2_descs = oas_descs.oas2_descs;
data.oas3_descs = oas_descs.oas3_descs;
data.utils = {};
data.utils.yaml = yaml;
data.utils.getSample = common.getSample;
data.utils.schemaToArray = common.schemaToArray;
data.utils.slugify = common.slugify;
data.utils.linkCase = function(s) {
return s[0].toLowerCase()+s.substr(1);
};
defaults.search = true;
defaults.theme = 'darkula';
defaults.headings = 2;
defaults.templateCallback = function(template,stage,data) { return data; };
options = Object.assign({},defaults,options);
let data = {};
if (options.verbose) console.warn('starting deref',api.info.title);
if (api.components) {
data.components = clone(api.components);
}
else {
data.components = {};
}
data.api = dereference(api,api,{verbose:options.verbose,$ref:'x-widdershins-oldRef'});
if (options.verbose) console.warn('finished deref');
if (data.api.components && data.api.components.schemas && data.api.components.schemas["x-widdershins-oldRef"]) {
delete data.api.components.schemas["x-widdershins-oldRef"];
}
if (typeof templates === 'undefined') {
templates = dot.process({ path: path.join(__dirname, '..', 'templates', 'openapi3') });
}
if (options.user_templates) {
templates = Object.assign(templates, dot.process({ path: options.user_templates }));
}
data.options = options;
data.translations = {};
templates.translations(data);
//? seen in akka-scala
return true;
};
let allSecurity = [];
if (api.components && api.components.securitySchemes) {
for (let s in api.components.securitySchemes) {
let entry = {};
entry[s] = api.components.securitySchemes[s];
allSecurity.push(entry);
}
}
let authData = getAuthData(allSecurity,api);
obj = Object.assign(obj,authData);
api = deref(api,api,{$ref:'x-oldref'});
obj.messages = [];
let message = {};
let vOptions = {lint:defaults.lint};
if (defaults.stools && defaults.swagger) {
stools.specs.v2_0.validate(defaults.swagger,function(err,result){
if (err) console.error(util.inspect(err));
if (result.errors) {
for (let e of result.errors) {
let message = {};
message.level = 'Error';
message.elementType = 'Path';
message.message = e.message;
message.elementId = e.path.join('/');
obj.messages.push(message);
if (defaults.verbose) console.log(message);
defaults.search = true;
defaults.theme = 'darkula';
defaults.headingLevel = 2;
defaults.templateCallback = function(template,stage,data) { return data; };
options = Object.assign({},defaults,options);
let data = {};
if (options.verbose) console.log('starting deref',api.info.title);
if (api.components) {
data.components = clone(api.components);
}
else {
data.components = {};
}
data.api = dereference(api,api,{verbose:options.verbose,$ref:'x-widdershins-oldRef'});
if (options.verbose) console.log('finished deref');
if (data.api.components && data.api.components.schemas && data.api.components.schemas["x-widdershins-oldRef"]) {
delete data.api.components.schemas["x-widdershins-oldRef"];
}
if (typeof templates === 'undefined') {
templates = dot.process({ path: path.join(__dirname, 'templates', 'openapix') });
}
if (options.user_templates) {
templates = Object.assign(templates, dot.process({ path: options.user_templates }));
}
data.translations = {};
templates.translations(data);
data.version = (data.api.info.version.toLowerCase().startsWith('v') ? data.api.info.version : 'v'+data.api.info.version);
function apply(overlay,openapi,options){
const src = deref(clone(openapi));
for (let update of overlay.updates||overlay.overlay.updates) {
try {
const result = jmespath.search(src,update.target);
const rtype = truetype(result);
const present = findObj(src,result);
if (options.verbose) {
console.warn('result',util.inspect({update:update,result:result,rtype:rtype,locn:present},{depth:Infinity,colors:true}));
}
if (rtype === 'object') {
Object.assign(result,update.value);
}
else if (rtype === 'array') {
if (present.found) {
if (Array.isArray(update.value)) {
for (let value of update.value) {
result.push(value);
function convertInner(api, options, callback) {
let data = {};
if (options.verbose) console.warn('starting deref',api.info.title);
data.api = dereference(api,api,{verbose:options.verbose,$ref:'x-widdershins-oldRef'});
if (options.verbose) console.warn('finished deref');
data.version = (data.api.info && data.api.info.version && data.api.info.version.toLowerCase().startsWith('v') ? data.api.info.version : 'v'+(data.api.info && data.api.info.version ? data.api.info.version : '1.0.0'));
let header = {};
header.title = api.info && api.info.title ? ' ' + data.version : ' 1.0.0';
header.language_tabs = options.language_tabs;
header.headingLevel = Math.max(options.headings || 0, 3);
header.toc_footers = [];
if (api.externalDocs) {
if (api.externalDocs.url) {
header.toc_footers.push('<a href="' + api.externalDocs.url + '">' + (api.externalDocs.description ? api.externalDocs.description : 'External Docs') + '</a>');
}
}
if (options.toc_footers) {