How to use the swagger2openapi.convertUrl function in swagger2openapi

To help you get started, we’ve selected a few swagger2openapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mrin9 / RapiPdf / src / spec-parser.js View on Github external
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;
github mrin9 / RapiDoc / src / utils / parse-utils.js View on Github external
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
    };
github mrin9 / RapiDoc / src / utils / spec-parser.js View on Github external
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
    };