Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fixed visitDate and visitTime methods to return date only or time only #523

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class TypeToJsonSchemaVisitor implements TypeVisitor<JsonObjectBuilder>
private static final String INTEGER = "integer";
private static final String NULL = "null";
private static final String DATE_TIME = "date-time";
private static final String DATE_ONLY = "date";
private static final String STRING = "string";
private static final String BOOLEAN = "boolean";
private static final String ARRAY = "array";
Expand Down Expand Up @@ -177,7 +178,7 @@ public JsonObjectBuilder visitDate(DateOnlyResolvedType dateOnlyTypeDefinition)
{
return this.factory.createObjectBuilder()
.add(TYPE, STRING)
.add(FORMAT, DATE_TIME);
.add(FORMAT, DATE_ONLY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,21 @@
"name": "date-only",
"parentTypes": [],
"required": true,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"root\" type=\"date\"/>\n</schema>\n",
"type": null,
"xml": null
}
],
"required": false,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"release_date\" type=\"date\"/>\n</schema>\n",
"type": "date-only",
"xml": null
}
],
"required": true,
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date-time\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"Release\" type=\"tns:Release\"/>\n <complexType name=\"Release\">\n <sequence>\n <element minOccurs=\"0\" name=\"release_date\" type=\"date\"/>\n <any maxOccurs=\"unbounded\" minOccurs=\"0\" processContents=\"skip\"/>\n </sequence>\n </complexType>\n</schema>\n",
"type": "object",
"xml": null
Expand Down Expand Up @@ -187,21 +187,21 @@
"name": "date-only",
"parentTypes": [],
"required": true,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"root\" type=\"date\"/>\n</schema>\n",
"type": null,
"xml": null
}
],
"required": false,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"release_date\" type=\"date\"/>\n</schema>\n",
"type": "date-only",
"xml": null
}
],
"required": true,
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date-time\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"Release\" type=\"tns:Release\"/>\n <complexType name=\"Release\">\n <sequence>\n <element minOccurs=\"0\" name=\"release_date\" type=\"date\"/>\n <any maxOccurs=\"unbounded\" minOccurs=\"0\" processContents=\"skip\"/>\n </sequence>\n </complexType>\n</schema>\n",
"type": "Release",
"xml": null
Expand Down Expand Up @@ -313,21 +313,21 @@
"name": "date-only",
"parentTypes": [],
"required": true,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"root\" type=\"date\"/>\n</schema>\n",
"type": null,
"xml": null
}
],
"required": false,
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date-time\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"type\":\"string\",\"format\":\"date\",\"definitions\":{},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"release_date\" type=\"date\"/>\n</schema>\n",
"type": "date-only",
"xml": null
}
],
"required": true,
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date-time\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toJsonSchema": "{\"$ref\":\"#/definitions/Release\",\"definitions\":{\"Release\":{\"type\":\"object\",\"properties\":{\"release_date\":{\"type\":\"string\",\"format\":\"date\"}}}},\"$schema\":\"http://json-schema.org/draft-04/schema#\"}",
"toXmlSchema": "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://validationnamespace.raml.org\" attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targetNamespace=\"http://validationnamespace.raml.org\">\n <element name=\"Release\" type=\"tns:Release\"/>\n <complexType name=\"Release\">\n <sequence>\n <element minOccurs=\"0\" name=\"release_date\" type=\"date\"/>\n <any maxOccurs=\"unbounded\" minOccurs=\"0\" processContents=\"skip\"/>\n </sequence>\n </complexType>\n</schema>\n",
"type": "object",
"xml": null
Expand Down