function checkPaths()

in functions/version-policy.js [11:43]


function checkPaths(targetVal) {
  const oas2 = targetVal.swagger;

  if (oas2) {
    const basePath = targetVal.basePath || '';
    const version = getVersion(basePath);
    if (version) {
      return [
        {
          message: `Version segment "${version}" in basePath violates Azure versioning policy.`,
          path: ['basePath'],
        },
      ];
    }
  }

  // We did not find a major version in basePath, so now check the paths

  const { paths } = targetVal;
  const errors = [];
  if (paths && typeof paths === 'object') {
    Object.keys(paths).forEach((path) => {
      const version = getVersion(path);
      if (version) {
        errors.push({
          message: `Version segment "${version}" in path violates Azure versioning policy.`,
          path: ['paths', path],
        });
      }
    });
  }
  return errors;
}