How to use the swagger-converter.convert function in swagger-converter

To help you get started, we’ve selected a few swagger-converter 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 sky-uk / api-explorer / packages / apiexplorer / src / infrastructure / loaders / swagger1Loader.js View on Github external
async.map(apis, executeFetch, (err, result) => {
        if (err) {
          onLoadError(`Error loading Swagger 1.x apis: ${err}`)
          console.error(err)
        } else {
          onLoadProgress(`Loading of Swagger spec 1.x completed.`)

          let apiDeclarations = {}
          result.forEach(element => { apiDeclarations[element.path] = element.result })

          onLoadProgress('Started to convert Swagger 1.x to Swagger 2.0....')
          const swagger2Document = SwaggerConverter.convert(apiSpec, apiDeclarations)
          onLoadProgress('Convertion from Swagger 1.x to Swagger 2.0 completed!')
          swagger2Document.info.title = swagger2Document.info.title === 'Title was not specified' ? 'API' : swagger2Document.info.title

          swagger2JsonLoader(swagger2Document, config.friendlyName, config.slug, defaultHost, { onLoadProgress, onNewAPI, onNewOperation, onNewDefinition, onLoadCompleted, onLoadError })
        }
      })
    })
github LucyBot-Inc / api-spec-converter / lib / formats / swagger_1.js View on Github external
this.converters.swagger_2 = Promise.method((swagger1, passthrough) => {
    passthrough = passthrough || {};
    passthrough.buildTagsFromPaths = passthrough.buildTagsFromPaths !== false;
    var swagger2 = SwaggerConverter.convert(
      swagger1.spec,
      swagger1.subResources,
      passthrough
    );

    if (swagger2.info.title === 'Title was not specified')
      swagger2.info.title = swagger2.host;
    return swagger2;
  });

swagger-converter

Converts Swagger documents from version 1.x to version 2.0

MIT
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis