当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript helper.ProblemReporter.getProblems方法代码示例

本文整理汇总了TypeScript中@maxxton/microdocs-core/helpers/problem/problem-reporter.helper.ProblemReporter.getProblems方法的典型用法代码示例。如果您正苦于以下问题:TypeScript helper.ProblemReporter.getProblems方法的具体用法?TypeScript helper.ProblemReporter.getProblems怎么用?TypeScript helper.ProblemReporter.getProblems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@maxxton/microdocs-core/helpers/problem/problem-reporter.helper.ProblemReporter的用法示例。


在下文中一共展示了helper.ProblemReporter.getProblems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: findEndpoint

/**
 * Find an endpoint in a given project
 * @param producerProject project to search in
 * @param path path of the endpoint
 * @param method request method of the endpoint
 * @returns {null,Path} returns Path or null if it does not exists
 */
function findEndpoint( clientEndpoint: Path, clientPath: string, clientMethod: string, clientProject:Project, producerProject: Project ): Path {
  let bestMatch: Path = null;
  let errorCount      = 0;
  let warningCount    = 0;
  let variableCount   = 0;
  for ( let producerPath in producerProject.paths ) {
    if ( producerProject.paths[ producerPath ][ clientMethod ] ) {
      // match via wildcards in regexp
      const expression = '^' + producerPath.replace( new RegExp( "\/", 'g' ), '\/' ).replace( new RegExp( "\\{.*?\\}", 'g' ), '([^\/]+)' ) + '$';
      const regExp     = new RegExp( expression );
      const match      = clientPath.match( regExp );

      if ( match && match.length >= 1 ) {
        // build endpoint if match
        const endpoint         = producerProject.paths[ producerPath ][ clientMethod ];
        endpoint.path          = producerPath;
        endpoint.requestMethod = clientMethod;
        let variables          = 0;
        if ( endpoint.parameters ) {
          variables = endpoint.parameters.filter( param => param.in === ParameterPlacings.PATH ).length;
        }

        // check problems
        const report = new ProblemReporter();
        checkPathParameters( clientEndpoint, endpoint, clientProject, producerProject, report );
        let resultErrorCount   = report.getProblems().filter( problem => problem.level === ProblemLevels.ERROR ).length;
        let resultWarningCount = report.getProblems().filter( problem => problem.level === ProblemLevels.WARNING ).length;

        // set as best match if there is no match or it has the fewest problems
        if ( bestMatch == null || variables < variableCount || (variables == variableCount && (resultErrorCount > errorCount || (resultErrorCount == errorCount && resultWarningCount > warningCount))) ) {
          bestMatch     = endpoint;
          errorCount    = resultErrorCount;
          warningCount  = resultWarningCount;
          variableCount = variables;
        }
      }
    }
  }
  return bestMatch;
}
开发者ID:MaxxtonGroup,项目名称:microdocs,代码行数:47,代码来源:rest-dependencies.func.ts

示例2: resolveUsesDependencies

export function resolveUsesDependencies( pipe:Pipe<any>, project:Project, scope?:Project ) {
  if ( project.dependencies ) {
    for ( let depTitle in project.dependencies ) {
      if ( (scope && (scope.info.title === depTitle || scope.info.title === project.info.title)) || !scope ) {
        let dependency:Dependency = project.dependencies[ depTitle ];
        if ( dependency.type === DependencyTypes.USES ) {
          let reporter = new ProblemReporter( project );
          resolveUsesClient( pipe, reporter, project, dependency, depTitle, scope );
          if ( reporter.hasProblems() ) {
            reporter.publish( dependency, project );
            pipe.pipeline.addProblems( reporter.getProblems() );
          }
        }
      }
    }
  }
}
开发者ID:MaxxtonGroup,项目名称:microdocs,代码行数:17,代码来源:uses-dependencies.func.ts


注:本文中的@maxxton/microdocs-core/helpers/problem/problem-reporter.helper.ProblemReporter.getProblems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。