"date-time" without seconds fails validation
Issue #198
new
com.atlassian.oai:swagger-request-validator-restassured:2.2.2
Given the following definition
{
"openapi": "3.0.0",
"info": {
"title": "Service",
"version": "v1",
"description": "Service Api"
},
"tags": [
{
"name": "Request",
"description": "Request Data"
}
],
"paths": {
"/request": {
"post": {
"tags": [
"Request"
],
"summary": "Get request details",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json; charset=utf-8": {
"schema": {
"$ref": "#/components/schemas/RequestResponse"
}
}
}
}
},
"requestBody": {
"content": {
"application/json; charset=utf-8": {
"schema": {
"type": "object",
"properties": {
"requestId": {
"type": "string",
"minLength": 1,
"example": "requestreference",
"description": "Request reference"
}
},
"required": [
"requestId"
]
}
}
},
"description": "Request Body",
"required": true
}
}
}
},
"servers": [
{
"url": "/api/v1"
}
],
"components": {
"schemas": {
"RequestResponse": {
"type": "object",
"properties": {
"requestId": {
"type": "string"
},
"requestDate": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}
and RestAssured initialization
RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder()
.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.setAccept(MediaType.APPLICATION_JSON_UTF8_VALUE)
.addFilter(new OpenApiValidationFilter(OpenApiInteractionValidator.createFor(jsonSpecPath).build()));
RestAssured.requestSpecification = requestSpecBuilder.build();
the following response body fails validation:
{
"requestId": "abcdef123456789",
"requestDate": "2017-01-01T00:03Z"
}
Exception details:
com.atlassian.oai.validator.restassured.OpenApiValidationFilter$OpenApiValidationException: {
"messages" : [ {
"key" : "validation.response.body.schema.format",
"level" : "ERROR",
"message" : "[Path '/requestDate'] String \"2017-01-01T00:03Z\" is invalid against requested date format(s) [yyyy-MM-dd'T'HH:mm:ssZ, yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z]",
"context" : {
"requestPath" : "/api/v1/request",
"responseStatus" : 200,
"location" : "RESPONSE",
"requestMethod" : "POST"
}
} ]
}
OpenApiInteractionValidator.validate method doesn't fail when used outside of RestAssured filter.