Class OpenApiMatchers

java.lang.Object
com.atlassian.oai.validator.mockmvc.OpenApiMatchers

public class OpenApiMatchers extends Object
Factory for OpenAPI / Swagger assertions.
  • Constructor Details

    • OpenApiMatchers

      public OpenApiMatchers()
  • Method Details

    • isValid

      public org.springframework.test.web.servlet.ResultMatcher isValid(String specUrlOrPayload)
      Assert the result can be validated against the given Swagger v2 or OpenAPI v3 specification.

      The specification can be provided as a URL or an inline spec in JSON or YAML format.

      A URL can be an absolute HTTP/HTTPS URL, a File URL or a classpath location (without the classpath: scheme).

      For example:

           // Create from a publicly hosted HTTP location
           .isValid("http://api.myservice.com/swagger.json")
      
           // Create from a file on the local filesystem
           .isValid("file://Users/myuser/tmp/api.yaml");
      
           // Create from a classpath resource in the /api package
           .isValid("/api/swagger.json");
      
           // Create from a swagger JSON payload
           .isValid("{\"swagger\": \"2.0\", ...}")
       
      Parameters:
      specUrlOrPayload - The location of the Swagger JSON specification to use in the validator.
    • isValid

      public org.springframework.test.web.servlet.ResultMatcher isValid(OpenApiInteractionValidator validator)
      Assert the result can be validated using the given pre-configured validator.
      Parameters:
      validator - The pre-configured validator to use