public class OpenAPIExpectation extends ObjectWithJsonToString
Constructor and Description |
---|
OpenAPIExpectation() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Map<String,String> |
getOperationsAndResponses() |
String |
getSpecUrlOrPayload() |
int |
hashCode() |
static OpenAPIExpectation |
openAPIExpectation() |
static OpenAPIExpectation |
openAPIExpectation(String specUrlOrPayload)
Specify the OpenAPI to create matchers and example responses for:
|
static OpenAPIExpectation |
openAPIExpectation(String specUrlOrPayload,
Map<String,String> operationsAndResponses)
Specify the OpenAPI and operations and responses to create matchers and example responses for:
|
OpenAPIExpectation |
withOperationsAndResponses(Map<String,String> operationsAndResponses)
The operations and responses to use for each example response where the key is the operationId in the OpenAPI and the value if the response key (i.e.
|
OpenAPIExpectation |
withSpecUrlOrPayload(String specUrlOrPayload)
Specify the OpenAPI specification:
|
toString
fieldsExcludedFromEqualsAndHashCode
public static OpenAPIExpectation openAPIExpectation()
public static OpenAPIExpectation openAPIExpectation(String specUrlOrPayload, Map<String,String> operationsAndResponses)
// Create from a publicly hosted HTTP location (json or yaml) openAPIExpectation("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from a file on the local filesystem (json or yaml) openAPIExpectation("file://Users/myuser/git/mockserver/mockserver-core/src/test/resources/org/mockserver/openapi/openapi_petstore_example.json", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from a classpath resource in the /api package (json or yaml) openAPIExpectation("org/mockserver/openapi/openapi_petstore_example.json", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from an OpenAPI payload (json or yaml) openAPIExpectation("{\"openapi\": \"3.0.0\", \"info\": { ...", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" ));
specUrlOrPayload
- the OpenAPI to match against by URL or payloadoperationsAndResponses
- operations and responses to use for each example response where the key is the operationId in the OpenAPI and the value if the response key (i.e. "200", "400" or "default")public static OpenAPIExpectation openAPIExpectation(String specUrlOrPayload)
// Create from a publicly hosted HTTP location (json or yaml) openAPIExpectation("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from a file on the local filesystem (json or yaml) openAPIExpectation("file://Users/myuser/git/mockserver/mockserver-core/src/test/resources/org/mockserver/openapi/openapi_petstore_example.json", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from a classpath resource in the /api package (json or yaml) openAPIExpectation("org/mockserver/openapi/openapi_petstore_example.json", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" )); // Create from an OpenAPI payload (json or yaml) openAPIExpectation("{\"openapi\": \"3.0.0\", \"info\": { ...", ImmutableMap.of( "listPets", "500", "createPets", "default", "showPetById", "200" ));
specUrlOrPayload
- the OpenAPI to match against by URL or payloadpublic String getSpecUrlOrPayload()
public OpenAPIExpectation withSpecUrlOrPayload(String specUrlOrPayload)
// 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\": { ...");
specUrlOrPayload
- the OpenAPI to match against by URL or payloadpublic OpenAPIExpectation withOperationsAndResponses(Map<String,String> operationsAndResponses)
operationsAndResponses
- operations and responses to use for each example responsepublic boolean equals(Object o)
equals
in class ObjectWithReflectiveEqualsHashCodeToString
public int hashCode()
hashCode
in class ObjectWithReflectiveEqualsHashCodeToString
Copyright © 2022. All rights reserved.