java - Jackson JSON Schema generator for Joda date time -
i using jackson json schema module version 2.7.4
generate json schema of classes. in classes, have used joda datetime
object. schema object generated it's properties exploded (as shown below). possible convert date_time
?
"createddate":{ "type":"object", "id":"urn:jsonschema:org:joda:time:datetime", "properties":{ "weekofweekyear":{ "type":"integer" }, "weekyear":{ "type":"integer" }, "yearofera":{ "type":"integer" }, "secondofday":{ "type":"integer" }, "minuteofday":{ "type":"integer" }, "yearofcentury":{ "type":"integer" }, "centuryofera":{ "type":"integer" }, "millisofday":{ "type":"integer" }, "monthofyear":{ "type":"integer" }, "hourofday":{ "type":"integer" }, "minuteofhour":{ "type":"integer" }, "secondofminute":{ "type":"integer" }, "millisofsecond":{ "type":"integer" }, "year":{ "type":"integer" }, "dayofmonth":{ "type":"integer" }, "dayofweek":{ "type":"integer" }, "era":{ "type":"integer" }, "dayofyear":{ "type":"integer" }, "chronology":{ "type":"object", "id":"urn:jsonschema:org:joda:time:chronology", "properties":{ "zone":{ "type":"object", "id":"urn:jsonschema:org:joda:time:datetimezone", "properties":{ "id":{ "type":"string" }, "fixed":{ "type":"boolean" } } } } }, "zone":{ "type":"object", "$ref":"urn:jsonschema:org:joda:time:datetimezone" }, "millis":{ "type":"integer" }, "afternow":{ "type":"boolean" }, "beforenow":{ "type":"boolean" }, "equalnow":{ "type":"boolean" } } },
i'm not sure there support or joda in module. can replace generated joda schema own. this:
private void replacedatetime(jsonschema schema, class<?> clazz) { field[] fields = clazzfieldfinder.getallfields(clazz); (field field : fields) { string fieldname = field.getname(); if (field.gettype().equals(datetime.class)) { schema.asobjectschema().getproperties().remove(fieldname); stringschema stringschemadatetime = new stringschema(); stringschemadatetime.setformat(jsonvalueformat.date_time); schema.asobjectschema().getproperties().put(fieldname, stringschemadatetime); } } }
it removes generated schema joda , adds string/date_time format.
Comments
Post a Comment