From b71996ee505d9a070bb6c04534eeea9baf33a169 Mon Sep 17 00:00:00 2001 From: "ievgenii.tsybaiev" Date: Thu, 12 Jul 2018 20:52:33 +0300 Subject: [PATCH 1/3] Fixed visitDate and visitTime methods to return date only or time only --- .../v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java b/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java index 840e5520..319775f4 100644 --- a/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java +++ b/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java @@ -42,6 +42,8 @@ public class TypeToJsonSchemaVisitor implements TypeVisitor 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 TIME_ONLY = "time"; private static final String STRING = "string"; private static final String BOOLEAN = "boolean"; private static final String ARRAY = "array"; @@ -177,7 +179,7 @@ public JsonObjectBuilder visitDate(DateOnlyResolvedType dateOnlyTypeDefinition) { return this.factory.createObjectBuilder() .add(TYPE, STRING) - .add(FORMAT, DATE_TIME); + .add(FORMAT, DATE_ONLY); } @Override @@ -185,7 +187,7 @@ public JsonObjectBuilder visitDateTime(DateTimeResolvedType dateTimeTypeDefiniti { return this.factory.createObjectBuilder() .add(TYPE, STRING) - .add(FORMAT, DATE_TIME); + .add(FORMAT, TIME_ONLY); } @Override From f99e6fad3ecb87175aab277636fa57e229a5bf51 Mon Sep 17 00:00:00 2001 From: "ievgenii.tsybaiev" Date: Fri, 13 Jul 2018 14:20:31 +0300 Subject: [PATCH 2/3] fixed tests --- .../raml/v2/api/v10/ref-in-trait/model.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/raml-parser-2/src/test/resources/org/raml/v2/api/v10/ref-in-trait/model.json b/raml-parser-2/src/test/resources/org/raml/v2/api/v10/ref-in-trait/model.json index a30ed9bd..d69cad5b 100644 --- a/raml-parser-2/src/test/resources/org/raml/v2/api/v10/ref-in-trait/model.json +++ b/raml-parser-2/src/test/resources/org/raml/v2/api/v10/ref-in-trait/model.json @@ -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": "\n \n\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": "\n \n\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": "\n \n \n \n \n \n \n \n\n", "type": "object", "xml": null @@ -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": "\n \n\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": "\n \n\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": "\n \n \n \n \n \n \n \n\n", "type": "Release", "xml": null @@ -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": "\n \n\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": "\n \n\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": "\n \n \n \n \n \n \n \n\n", "type": "object", "xml": null From 973bfc92cae0d942343906ea7827aa10ccc6127f Mon Sep 17 00:00:00 2001 From: "ievgenii.tsybaiev" Date: Fri, 13 Jul 2018 15:01:51 +0300 Subject: [PATCH 3/3] reverted changes for TIME only --- .../v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java b/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java index 319775f4..0f317971 100644 --- a/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java +++ b/raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/type/TypeToJsonSchemaVisitor.java @@ -43,7 +43,6 @@ public class TypeToJsonSchemaVisitor implements TypeVisitor 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 TIME_ONLY = "time"; private static final String STRING = "string"; private static final String BOOLEAN = "boolean"; private static final String ARRAY = "array"; @@ -187,7 +186,7 @@ public JsonObjectBuilder visitDateTime(DateTimeResolvedType dateTimeTypeDefiniti { return this.factory.createObjectBuilder() .add(TYPE, STRING) - .add(FORMAT, TIME_ONLY); + .add(FORMAT, DATE_TIME); } @Override