Package io.vertx.openapi.validation
Interface ResponseValidator
-
public interface ResponseValidator
TheResponseValidator
requires theparameters
in a specific format to be able to parse and validate them. This is especially true for exploded parameters. The following table shows how the value of a parameter of a response must be stored in aValidatableResponse
object. For these examples the key of those values is always color. These are the initial values for each type:
- primitive (string) -> "blue"
- array -> ["blue","black","brown"]
- object -> { "R": 100, "G": 200, "B": 150 }
ValidatedRequest.getHeaders()
+--------+---------+-------+-----------+------------------------------------+-------------------------+ | style | explode | empty | primitive | array | object | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | simple | false | | blue | blue,black,brown | R,100,G,200,B,150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | simple | true | | blue | blue,black,brown | R=100,G=200,B=150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static ResponseValidator
create(Vertx vertx, OpenAPIContract contract)
Create a newResponseValidator
.Future<ValidatedResponse>
validate(ValidatableResponse params, String operationId)
Validates the passed response parameters against the operation defined in the related OpenAPI contract.
-
-
-
Method Detail
-
create
static ResponseValidator create(Vertx vertx, OpenAPIContract contract)
Create a newResponseValidator
.- Parameters:
vertx
- the related Vert.x instancecontract
- the relatedOpenAPIContract
- Returns:
- an instance of
ResponseValidator
.
-
validate
Future<ValidatedResponse> validate(ValidatableResponse params, String operationId)
Validates the passed response parameters against the operation defined in the related OpenAPI contract.- Parameters:
params
- the response parameters to validate.operationId
- the id of the related operation.- Returns:
- A succeeded Future with the parsed and validated response parameters, or a failed Future containing ValidationException.
-
-