Package org.mockserver.openapi
Class OpenApiContractTest
- java.lang.Object
-
- org.mockserver.openapi.OpenApiContractTest
-
public class OpenApiContractTest extends Object
Given an OpenAPI spec, builds representative example requests for each operation, sends them via an injected HTTP-send function, and validates each response against the spec.The class is HTTP-client-agnostic; the caller wires in the real client via the
httpSenderfunction passed torunContractTests(java.lang.String, java.lang.String, java.lang.String, java.util.function.Function<org.mockserver.model.HttpRequest, org.mockserver.model.HttpResponse>).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpenApiContractTest.ContractTestResultStructured result for a single contract test operation.
-
Constructor Summary
Constructors Constructor Description OpenApiContractTest(MockServerLogger mockServerLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<OpenApiContractTest.ContractTestResult>runContractTests(String specUrlOrPayload, String baseUrl, String operationIdFilter, Function<HttpRequest,HttpResponse> httpSender)Runs contract tests for each operation in the spec.
-
-
-
Constructor Detail
-
OpenApiContractTest
public OpenApiContractTest(MockServerLogger mockServerLogger)
-
-
Method Detail
-
runContractTests
public List<OpenApiContractTest.ContractTestResult> runContractTests(String specUrlOrPayload, String baseUrl, String operationIdFilter, Function<HttpRequest,HttpResponse> httpSender)
Runs contract tests for each operation in the spec.- Parameters:
specUrlOrPayload- URL, file path, or inline JSON/YAML of the OpenAPI specbaseUrl- base URL of the service under test (e.g. "http://localhost:8080")operationIdFilter- optional filter to test only a specific operationhttpSender- function that sends an HttpRequest and returns an HttpResponse- Returns:
- list of per-operation results
-
-