Class OpenAPIDefinition


public class OpenAPIDefinition extends RequestDefinition
Author:
jamesdbloom
  • Constructor Details

    • OpenAPIDefinition

      public OpenAPIDefinition()
  • Method Details

    • openAPI

      public static OpenAPIDefinition openAPI()
    • openAPI

      public static OpenAPIDefinition openAPI(String specUrlOrPayload)
      Specify the OpenAPI to match against by URL or payload and string as follows:

      // Create from a publicly hosted HTTP location (json or yaml) openAPI("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml")

      // Create from a file on the local filesystem (json or yaml) openAPI("file://Users/myuser/git/mockserver/mockserver-core/src/test/resources/org/mockserver/openapi/openapi_petstore_example.json");

      // Create from a classpath resource in the /api package (json or yaml) openAPI("org/mockserver/openapi/openapi_petstore_example.json");

      // Create from an OpenAPI payload (json or yaml) openAPI("{\"openapi\": \"3.0.0\", \"info\": { ...")

      Parameters:
      specUrlOrPayload - the OpenAPI to match against by URL or payload
      Returns:
      the OpenAPIMatcher
    • openAPI

      public static OpenAPIDefinition openAPI(String specUrlOrPayload, String operationId)
      Specify the OpenAPI and operationId to match against by URL or payload and string as follows:

      // Create from a publicly hosted HTTP location (json or yaml) openAPI("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml", "showPetById")

      // Create from a file on the local filesystem (json or yaml) openAPI("file://Users/myuser/git/mockserver/mockserver-core/src/test/resources/org/mockserver/openapi/openapi_petstore_example.json", "showPetById");

      // Create from a classpath resource in the /api package (json or yaml) openAPI("org/mockserver/openapi/openapi_petstore_example.json", "showPetById");

      // Create from an OpenAPI payload (json or yaml) openAPI("{\"openapi\": \"3.0.0\", \"info\": { ...", "showPetById")

      Parameters:
      specUrlOrPayload - the OpenAPI to match against by URL or payload
      operationId - operationId from the OpenAPI to match against i.e. "showPetById"
      Returns:
      the OpenAPIMatcher
    • getSpecUrlOrPayload

      public String getSpecUrlOrPayload()
    • withSpecUrlOrPayload

      public OpenAPIDefinition withSpecUrlOrPayload(String specUrlOrPayload)
      Specify the OpenAPI to match against by URL or payload as follows:

      // Create from a publicly hosted HTTP location (json or yaml) withSpecUrlOrPayload("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml")

      // Create from a file on the local filesystem (json or yaml) withSpecUrlOrPayload("file://Users/myuser/git/mockserver/mockserver-core/src/test/resources/org/mockserver/openapi/openapi_petstore_example.json");

      // Create from a classpath resource in the /api package (json or yaml) withSpecUrlOrPayload("org/mockserver/openapi/openapi_petstore_example.json");

      // Create from an OpenAPI payload (json or yaml) withSpecUrlOrPayload("{\"openapi\": \"3.0.0\", \"info\": { ...")

      Parameters:
      specUrlOrPayload - the OpenAPI to match against by URL or payload
      Returns:
      the OpenAPIMatcher
    • getOperationId

      public String getOperationId()
    • withOperationId

      public OpenAPIDefinition withOperationId(String operationId)
      Specify operationId from the OpenAPI to match against i.e. "showPetById"
      Parameters:
      operationId - operationId from the OpenAPI to match against i.e. "showPetById"
      Returns:
      the OpenAPIMatcher
    • getContextPathPrefix

      public String getContextPathPrefix()
    • withContextPathPrefix

      public OpenAPIDefinition withContextPathPrefix(String contextPathPrefix)
    • shallowClone

      public OpenAPIDefinition shallowClone()
      Specified by:
      shallowClone in class RequestDefinition
    • update

      public OpenAPIDefinition update(OpenAPIDefinition replaceRequest)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class RequestDefinition
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class RequestDefinition