How to use the api-spec-converter.ResourceReaders function in api-spec-converter

To help you get started, we’ve selected a few api-spec-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 APIs-guru / openapi-directory / scripts / collection.js View on Github external
}

function getCacheEntry(url) {
  var cacheIndex =_.findIndex(httpCache.cache,function(e){
    return e.url === url;
  });
  if (cacheIndex>=0)
    return httpCache.cache[cacheIndex];
  else {
    var cacheEntry = { url: url };
    httpCache.cache.push(cacheEntry);
    return cacheEntry;
  }
}

converter.ResourceReaders.url = function (url) {
  resolverContext.called = true;
  var options = {
    headers: {
      'Accept': 'application/json,*/*',
      'Accept-Language': 'en-GB,en;q=0.5'
    },
  retries : 10
  };
  var cacheEntry = getCacheEntry(url);
  if (cacheEntry && cacheEntry.etag && resolverContext.etag && resolverContext.format !== 'swagger_1') {
    options.headers['If-None-Match'] = cacheEntry.etag;
  }
  return makeRequest('get', url, options)
    .then(function(result){
      if (result[0].statusCode === 304) {
    throw new Error('Warning: 304 Not Modified');

api-spec-converter

Convert API descriptions between popular formats such as OpenAPI(fka Swagger), RAML, API Blueprint, WADL, etc.

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis