Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function ProcessSpec(specUrl, sortTags) {
let jsonParsedSpec; let convertedSpec; let
resolvedRefSpec;
const convertOptions = { patch: true, warnOnly: true };
const resolveOptions = { resolveCirculars: false };
try {
if (typeof specUrl === 'string') {
convertedSpec = await converter.convertUrl(specUrl, convertOptions);
} else {
convertedSpec = await converter.convertObj(specUrl, convertOptions);
}
resolvedRefSpec = await JsonRefs.resolveRefs(convertedSpec.openapi, resolveOptions);
jsonParsedSpec = resolvedRefSpec.resolved;
} catch (err) {
console.info('%c There was an issue while parsing the spec %o ', 'color:orangered', err); // eslint-disable-line no-console
}
const openApiSpec = jsonParsedSpec;
const methods = ['get', 'put', 'post', 'delete', 'patch', 'options', 'head'];
const tags = [];
let totalPathCount = 0;
// For each path find the tag and push it into the corrosponding tag
for (const path in openApiSpec.paths) {
const commonParams = openApiSpec.paths[path].parameters;
export default async function ProcessSpec(specUrl) {
let jsonParsedSpec;
let convertedSpec;
let resolvedRefSpec;
let resolveOptions;
let specLocation = ''; let
url;
const convertOptions = { patch: true, warnOnly: true };
try {
// JsonRefs cant load yaml files, so first use converter
if (typeof specUrl === 'string') {
// resolvedRefSpec = await JsonRefs.resolveRefsAt(specUrl, resolveOptions);
convertedSpec = await converter.convertUrl(specUrl, convertOptions);
specLocation = convertedSpec.source.trim();
if (specLocation.startsWith('/')) {
url = new URL(`.${specLocation}`, window.location.href);
specLocation = url.pathname;
}
} else {
// resolvedRefSpec = await JsonRefs.resolveRefs(specUrl, resolveOptions);
convertedSpec = await converter.convertObj(specUrl, convertOptions);
url = new URL(window.location.href);
specLocation = url.pathname;
}
// convertedSpec = await converter.convertObj(resolvedRefSpec.resolved, convertOptions);
resolveOptions = {
resolveCirculars: false,
location: specLocation, // location is important to specify to resolve relative external file references when using JsonRefs.resolveRefs() which takes an JSON object
};
export default async function ProcessSpec(specUrl, sortTags = false, attrApiKey = '', attrApiKeyLocation = '', attrApiKeyValue = '') {
let jsonParsedSpec;
let convertedSpec;
let resolvedRefSpec;
let resolveOptions;
let specLocation = '';
let url;
const convertOptions = { patch: true, warnOnly: true };
try {
// JsonRefs cant load yaml files, so first use converter
if (typeof specUrl === 'string') {
// resolvedRefSpec = await JsonRefs.resolveRefsAt(specUrl, resolveOptions);
convertedSpec = await converter.convertUrl(specUrl, convertOptions);
specLocation = convertedSpec.source.trim();
if (specLocation.startsWith('/')) {
url = new URL(`.${specLocation}`, window.location.href);
specLocation = url.pathname;
}
} else {
// resolvedRefSpec = await JsonRefs.resolveRefs(specUrl, resolveOptions);
convertedSpec = await converter.convertObj(specUrl, convertOptions);
url = new URL(window.location.href);
specLocation = url.pathname;
}
// convertedSpec = await converter.convertObj(resolvedRefSpec.resolved, convertOptions);
resolveOptions = {
resolveCirculars: false,
location: specLocation, // location is important to specify to resolve relative external file references when using JsonRefs.resolveRefs() which takes an JSON object
};