ng-swagger-gen.js
function applyTagFilter(models, services, options) {
  var i;
  // Normalize the included tag names
  const includeTags = options.includeTags;
  var included = null;
  if (includeTags && includeTags.length > 0) {
    included = [];
    for (i = 0; i < includeTags.length; i++) {
      included.push(tagName(includeTags[i], options));
    }
  }
  // Normalize the excluded tag names
  const excludeTags = options.excludeTags;
  var excluded = null;
  if (excludeTags && excludeTags.length > 0) {
    excluded = [];
    for (i = 0; i < excludeTags.length; i++) {
      excluded.push(tagName(excludeTags[i], options));
    }
  }
  // Filter out the unused models
  var ignoreUnusedModels = options.ignoreUnusedModels !== false;
  var usedModels = new Set();
  const addToUsed = (dep) => usedModels.add(dep);
  for (var serviceName in services) {
    var include =
      (!included || included.indexOf(serviceName) >= 0) &&
      (!excluded || excluded.indexOf(serviceName) < 0);
    if (!include) {
      // This service is skipped - remove it
      console.info(
        'Ignoring service ' + serviceName + ' because it was not included'
      );
      delete services[serviceName];
    } else if (ignoreUnusedModels) {
      // Collect the models used by this service
      var service = services[serviceName];
      service.serviceDependencies.forEach(addToUsed);
      service.serviceErrorDependencies.forEach(addToUsed);
    }
  }

  if (ignoreUnusedModels) {
    // Collect the model dependencies of models, so unused can be removed
    var allDependencies = new Set();
    usedModels.forEach(dep =>
      collectDependencies(allDependencies, dep, models)
    );

    // Remove all models that are unused
    for (var modelName in models) {
      var model = models[modelName];
      if (!allDependencies.has(model.modelClass)) {
        // This model is not used - remove it
        console.info(
          'Ignoring model ' +
            modelName +
            ' because it was not used by any service'
        );
        delete models[modelName];
      }
    }
  }
}
function applyTagFilter(models, services, options) {
  var i;
  // Normalize the included tag names
  const includeTags = options.includeTags;
  var included = null;
  if (includeTags && includeTags.length > 0) {
    included = [];
    for (i = 0; i < includeTags.length; i++) {
      included.push(tagName(includeTags[i], options));
    }
  }
  // Normalize the excluded tag names
  const excludeTags = options.excludeTags;
  var excluded = null;
  if (excludeTags && excludeTags.length > 0) {
    excluded = [];
    for (i = 0; i < excludeTags.length; i++) {
      excluded.push(tagName(excludeTags[i], options));
    }
  }
  // Filter out the unused models
  var ignoreUnusedModels = options.ignoreUnusedModels !== false;
  var usedModels = new Set();
  const addToUsed = (dep) => usedModels.add(dep);
  for (var serviceName in services) {
    var include =
      (!included || included.indexOf(serviceName) >= 0) &&
      (!excluded || excluded.indexOf(serviceName) < 0);
    if (!include) {
      // This service is skipped - remove it
      console.info(
        'Ignoring service ' + serviceName + ' because it was not included'
      );
      delete services[serviceName];
    } else if (ignoreUnusedModels) {
      // Collect the models used by this service
      var service = services[serviceName];
      service.serviceDependencies.forEach(addToUsed);
      service.serviceErrorDependencies.forEach(addToUsed);
    }
  }

  if (ignoreUnusedModels) {
    // Collect the model dependencies of models, so unused can be removed
    var allDependencies = new Set();
    usedModels.forEach(dep =>
      collectDependencies(allDependencies, dep, models)
    );

    // Remove all models that are unused
    for (var modelName in models) {
      var model = models[modelName];
      if (!allDependencies.has(model.modelClass)) {
        // This model is not used - remove it
        console.info(
          'Ignoring model ' +
            modelName +
            ' because it was not used by any service'
        );
        delete models[modelName];
      }
    }
  }
}
function applyTagFilter ( models , services , options ) { var i ; // Normalize the included tag names const includeTags = options . includeTags ; var included = null ; if ( includeTags && includeTags . length > 0 ) { included = [ ] ; for ( i = 0 ; i < includeTags . length ; i ++ ) { included . push ( tagName ( includeTags [ i ] , options ) ) ; } } // Normalize the excluded tag names const excludeTags = options . excludeTags ; var excluded = null ; if ( excludeTags && excludeTags . length > 0 ) { excluded = [ ] ; for ( i = 0 ; i < excludeTags . length ; i ++ ) { excluded . push ( tagName ( excludeTags [ i ] , options ) ) ; } } // Filter out the unused models var ignoreUnusedModels = options . ignoreUnusedModels !== false ; var usedModels = new Set ( ) ; const addToUsed = ( dep ) => usedModels . add ( dep ) ; for ( var serviceName in services ) { var include = ( ! included || included . indexOf ( serviceName ) >= 0 ) && ( ! excluded || excluded . indexOf ( serviceName ) < 0 ) ; if ( ! include ) { // This service is skipped - remove it console . info ( 'Ignoring service ' + serviceName + ' because it was not included' ) ; delete services [ serviceName ] ; } else if ( ignoreUnusedModels ) { // Collect the models used by this service var service = services [ serviceName ] ; service . serviceDependencies . forEach ( addToUsed ) ; service . serviceErrorDependencies . forEach ( addToUsed ) ; } } if ( ignoreUnusedModels ) { // Collect the model dependencies of models, so unused can be removed var allDependencies = new Set ( ) ; usedModels . forEach ( dep => collectDependencies ( allDependencies , dep , models ) ) ; // Remove all models that are unused for ( var modelName in models ) { var model = models [ modelName ] ; if ( ! allDependencies . has ( model . modelClass ) ) { // This model is not used - remove it console . info ( 'Ignoring model ' + modelName + ' because it was not used by any service' ) ; delete models [ modelName ] ; } } } }
Applies a filter over the given services, keeping only the specific tags.
Also optionally removes any unused models, even services are filtered.
Applies a filter over the given services keeping only the specific tags . Also optionally removes any unused models even services are filtered .