Closed
Description
My POJO element is:
@XmlElement(name = "TrackDt", required = true)
@XmlSchemaType(name = "date")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT")
protected XMLGregorianCalendar trackDt;
During generating Json schema, I am using both JAXB and Jackson annotaions by adding introspectors like below:
JacksonAnnotationIntrospector primary = new JacksonAnnotationIntrospector();
JaxbAnnotationIntrospector secondary = new
JaxbAnnotationIntrospector(typeFactory);
mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(primary, secondary));
The generated Json schema looks like:
..
"TrackDt": {
"type": "string",
"format": "date-time"
}
..
"required": ["TrackDt"]
A Json request example:
{
....
"TrackDt": "2017-06-13",
....
}
While validating this JSON instance against the schema, the date is validated and the response contains the dates according to the pattern specified in @jsonformat annotation.
Now , I want to add JAXB annotation introspector and use JAXB annotations also. But the validator throws following error:
Exception while reading input message; nested exception is
com.github.fge.jsonschema.core.exceptions.ProcessingException: fatal: string
"2017-06-13" 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] level: "fatal" schema:
{"loadingURI":"#","pointer":"../properties/TrackDt"}
instance: {"pointer":"/TrackDt"} domain: "validation" keyword: "format"
attribute: "date-time" value: "2017-06-13" expected: ["yyyy-MM-
dd'T'HH:mm:ssZ","yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z"]
Metadata
Metadata
Assignees
Labels
No labels