Class OpenApiCoverageReporter

java.lang.Object
com.shaft.api.internal.OpenApiCoverageReporter

public final class OpenApiCoverageReporter extends Object
Collects OpenAPI operation coverage from SHAFT API requests and reuses parsed validators.
  • Method Details

    • validationFilter

      public static com.atlassian.oai.validator.restassured.OpenApiValidationFilter validationFilter(String specUrlOrDefinition)
      Returns a cached OpenAPI validation filter for the supplied spec.
      Parameters:
      specUrlOrDefinition - OpenAPI URL, path, or inline definition
      Returns:
      cached REST Assured validation filter
    • start

      public static void start(String specUrlOrDefinition, int threshold)
      Enables coverage collection for a spec and remembers the current threshold.
      Parameters:
      specUrlOrDefinition - OpenAPI URL, path, or inline definition
      threshold - required coverage percentage from 0 to 100
    • recordInteraction

      public static void recordInteraction(String specUrlOrDefinition, RestActions.RequestType requestType, String requestPath, Throwable failure)
      Records one API interaction against the configured OpenAPI document.
      Parameters:
      specUrlOrDefinition - OpenAPI URL, path, or inline definition
      requestType - HTTP method
      requestPath - request path
      failure - validation failure, when one occurred
    • reportAndGetThresholdFailure

      public static AssertionError reportAndGetThresholdFailure()
      Logs and attaches the OpenAPI coverage report, returning a threshold failure when configured.
      Returns:
      threshold failure, or null when the run satisfies configured coverage