openapi expectation failure
Describe the issue Set up of an OpenAPI expectation fails on mockserver
What you are trying to do Initialising a set of expectations from an OpenAPI spec.
MockServer version 5.11.2 client running against MockServerContainer (1.15) with latest Docker image
To Reproduce
`
private static final MockServerContainer mockServerContainer;
private static final String MCM_OPENAPI = "https://myapi/v3/api-docs";
static {
mockServerContainer = new MockServerContainer(DockerImageName.parse("jamesdbloom/mockserver"))
.withReuse(true);
mockServerContainer.start();
new MockServerClient(mockServerContainer.getContainerIpAddress(),
mockServerContainer.getServerPort())
.when(
openAPI(MCM_OPENAPI,
"status")
)
.respond(response().withBody("some_response_body"));
}
`
Expected behaviour Expectation to be successfully registered.
MockServer Log 2020-12-17 17:10:28 org.mockserver.log.MockServerEventLog SEVERE exception processing:
{
"method" : "PUT",
"path" : "/mockserver/expectation",
"headers" : {
"content-type" : [ "application/json; charset=utf-8" ],
"host" : [ "localhost:55018" ],
"accept-encoding" : [ "gzip,deflate" ],
"content-length" : [ "363" ],
"connection" : [ "keep-alive" ]
},
"keepAlive" : true,
"secure" : false,
"body" : {
"type" : "STRING",
"string" : "{\n "id" : "5a3c0c48-7727-40b2-b1c0-4f406e2d04f8",\n "priority" : 0,\n "httpRequest" : {\n "operationId" : "status",\n "specUrlOrPayload" : "https://myapi/v3/api-docs"\n },\n "httpResponse" : {\n "body" : "some_response_body"\n },\n "times" : {\n "unlimited" : true\n },\n "timeToLive" : {\n "unlimited" : true\n }\n}",
"contentType" : "application/json; charset=utf-8"
}
}
error:
2 errors:
-
object instance has properties which are not allowed by the schema: ["id","priority"]
-
object instance has properties which are not allowed by the schema: ["operationId","specUrlOrPayload"] for field "/httpRequest"
Resolved by upgrading to 1.15.1 of testcontainer dependency and 5.11.2 mockserver Docker image;
testImplementation("org.testcontainers:mockserver:1.15.1")