public async validateRoundTrip()

in lib/liveValidation/liveValidator.ts [749:836]


  public async validateRoundTrip(
    requestResponseObj: RequestResponsePair
  ): Promise<LiveValidationResult> {
    const startTime = Date.now();
    if (this.operationSearcher === undefined) {
      const msg = "operationSearcher should be initialized before this call.";
      const runtimeException = { code: C.ErrorCodes.RoundtripValidationError.name, message: msg };
      return {
        isSuccessful: undefined,
        errors: [],
        operationInfo: {
          operationId: "",
          apiVersion: "",
        },
        runtimeException: runtimeException,
      };
    }
    const { info, error } = this.getResolvedOperationInfo(requestResponseObj.liveRequest);
    console.log(info.operationId);
    if (error !== undefined) {
      this.logging(
        `ErrorMessage:${error.message}.ErrorStack:${error.stack}`,
        LiveValidatorLoggingLevels.error,
        LiveValidatorLoggingTypes.error,
        "Oav.liveValidator.validateRoundTrip",
        undefined,
        info.validationRequest
      );
      return {
        isSuccessful: undefined,
        errors: [],
        runtimeException: error,
        operationInfo: info,
      };
    }

    let errors: LiveValidationIssue[] = [];
    let runtimeException;
    try {
      const res = diffRequestResponse(
        requestResponseObj,
        info,
        this.loader?.getResolvedJsonLoader()!
      );
      for (const re of res) {
        if (re !== undefined) {
          errors.push(re);
        }
      }
    } catch (validationErr) {
      const msg =
        `An error occurred while validating the live request for operation ` +
        `"${info.operationId}". The error is:\n ` +
        `${util.inspect(validationErr, { depth: null })}`;
      runtimeException = { code: C.ErrorCodes.RoundtripValidationError.name, message: msg };
      this.logging(
        msg,
        LiveValidatorLoggingLevels.error,
        LiveValidatorLoggingTypes.error,
        "Oav.liveValidator.validateRoundTrip",
        undefined,
        info.validationRequest
      );
      return {
        isSuccessful: undefined,
        operationInfo: info,
        errors,
        runtimeException,
      };
    }
    const elapsedTime = Date.now() - startTime;
    this.logging(
      `Complete roundtrip validation`,
      LiveValidatorLoggingLevels.info,
      LiveValidatorLoggingTypes.perfTrace,
      "Oav.liveValidator.validateRoundTrip",
      elapsedTime,
      info.validationRequest
    );
    delete info.validationRequest;
    delete info.operationMatch;
    return {
      isSuccessful: runtimeException ? undefined : errors.length === 0,
      operationInfo: info,
      errors,
      runtimeException,
    };
  }