jsonschema and date type

Tags: , , ,

I’m just getting started with jsonschema and an example under “Using jsonschema2pojo within your Java project (embedded)” in https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started

having in mind data types of jsonschema listed here https://developers.google.com/discovery/v1/type-format?hl=en

my schema object can be described as

    "$schema": "http://json-schema.org/draft-04/schema",
    "description": "Document",
    "type": "object",

    "properties": {
        "displayDate": { "type": "date" },
        "displayName": { "type": "string" }

unfortunately a generated Pojo object will be

package com.example;

public interface Document {

   java.lang.Object getDisplayDate();

   void setDisplayDate(java.lang.Object arg0);

   java.lang.String getDisplayName();

   void setDisplayName(java.lang.String arg0);


has a member “displayDate” of a type Object instead of expected Date. Why?


date is not a valid value for type. displayDate should be defined as

{ "type": "string", "format": "date" }

I don’t know if jsonschema2pojo will convert that to a Date object like you want, but it seems that it is defaulting to Object instead of throwing an error when it encounters the invalid value for type.

Source: stackoverflow