Package org.mockserver.openapi
Class OpenApiContractTest
java.lang.Object
org.mockserver.openapi.OpenApiContractTest
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
httpSender function passed to runContractTests(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 ClassesModifier and TypeClassDescriptionstatic classStructured result for a single contract test operation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrunContractTests(String specUrlOrPayload, String baseUrl, String operationIdFilter, Function<HttpRequest, HttpResponse> httpSender) Runs contract tests for each operation in the spec.
-
Constructor Details
-
OpenApiContractTest
-
-
Method Details
-
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
-