public void run()

in cli/src/main/java/org/apache/servicecomb/toolkit/cli/CheckStyleBase.java [59:98]


  public void run() {

    FactoryOptions factoryOptions;
    try {
      factoryOptions = loadFactoryOptions();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    String yaml = null;
    try {
      yaml = loadFileContent(filePath);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    SwaggerParseResult parseResult = StyleCheckParser.parseYaml(yaml);
    OpenAPI openAPI = parseResult.getOpenAPI();
    if (openAPI == null) {
      StringJoiner sj = new StringJoiner("\n");
      if (CollectionUtils.isNotEmpty(parseResult.getMessages())) {
        for (String message : parseResult.getMessages()) {
          sj.add(message);
        }
      }
      throw new RuntimeException(sj.toString());
    }

    OasSpecValidator oasSpecValidator = createOasSpecValidator(factoryOptions);

    List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI);
    if (CollectionUtils.isNotEmpty(violations)) {
      for (OasViolation violation : violations) {
        LOGGER.info("path  : {}\nerror : {}\n------",
            OasObjectPropertyLocation.toPathString(violation.getLocation()), violation.getError());
      }
      throw new ValidationFailedException("check not passed");
    }
    LOGGER.info("Everything is good");
  }