Skip to content

Commit 3888079

Browse files
committed
Correct for date-time
1 parent d27916a commit 3888079

File tree

3 files changed

+31
-49
lines changed

3 files changed

+31
-49
lines changed

docs/domains/Domain.json

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@
6868
"channelName"
6969
]
7070
},
71-
"Chronology": {
72-
"type": "object",
73-
"properties": {}
74-
},
7571
"Cluster": {
7672
"type": "object",
7773
"properties": {
@@ -126,28 +122,15 @@
126122
"clusterName"
127123
]
128124
},
129-
"DateTime": {
130-
"type": "object",
131-
"properties": {
132-
"iChronology": {
133-
"$ref": "#/definitions/Chronology"
134-
},
135-
"iMillis": {
136-
"type": "number"
137-
}
138-
},
139-
"required": [
140-
"iMillis"
141-
]
142-
},
143125
"DomainCondition": {
144126
"type": "object",
145127
"properties": {
146128
"reason": {
147129
"type": "string"
148130
},
149131
"lastTransitionTime": {
150-
"$ref": "#/definitions/DateTime"
132+
"format": "date-time",
133+
"type": "string"
151134
},
152135
"message": {
153136
"type": "string"
@@ -156,7 +139,8 @@
156139
"type": "string"
157140
},
158141
"lastProbeTime": {
159-
"$ref": "#/definitions/DateTime"
142+
"format": "date-time",
143+
"type": "string"
160144
},
161145
"status": {
162146
"type": "string"
@@ -297,7 +281,8 @@
297281
"minimum": 0
298282
},
299283
"startTime": {
300-
"$ref": "#/definitions/DateTime"
284+
"format": "date-time",
285+
"type": "string"
301286
},
302287
"conditions": {
303288
"type": "array",
@@ -392,7 +377,8 @@
392377
"type": "string"
393378
},
394379
"activationTime": {
395-
"$ref": "#/definitions/DateTime"
380+
"format": "date-time",
381+
"type": "string"
396382
},
397383
"subsystems": {
398384
"type": "array",
@@ -1005,7 +991,8 @@
1005991
"type": "string"
1006992
},
1007993
"deletionTimestamp": {
1008-
"$ref": "#/definitions/DateTime"
994+
"format": "date-time",
995+
"type": "string"
1009996
},
1010997
"labels": {
1011998
"$ref": "#/definitions/Map"
@@ -1032,7 +1019,8 @@
10321019
"type": "string"
10331020
},
10341021
"creationTimestamp": {
1035-
"$ref": "#/definitions/DateTime"
1022+
"format": "date-time",
1023+
"type": "string"
10361024
},
10371025
"name": {
10381026
"type": "string"

docs/domains/index.html

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -988,10 +988,6 @@
988988
"channelName"
989989
]
990990
},
991-
"Chronology": {
992-
"type": "object",
993-
"properties": {}
994-
},
995991
"Cluster": {
996992
"type": "object",
997993
"properties": {
@@ -1046,28 +1042,15 @@
10461042
"clusterName"
10471043
]
10481044
},
1049-
"DateTime": {
1050-
"type": "object",
1051-
"properties": {
1052-
"iChronology": {
1053-
"$ref": "#/definitions/Chronology"
1054-
},
1055-
"iMillis": {
1056-
"type": "number"
1057-
}
1058-
},
1059-
"required": [
1060-
"iMillis"
1061-
]
1062-
},
10631045
"DomainCondition": {
10641046
"type": "object",
10651047
"properties": {
10661048
"reason": {
10671049
"type": "string"
10681050
},
10691051
"lastTransitionTime": {
1070-
"$ref": "#/definitions/DateTime"
1052+
"format": "date-time",
1053+
"type": "string"
10711054
},
10721055
"message": {
10731056
"type": "string"
@@ -1076,7 +1059,8 @@
10761059
"type": "string"
10771060
},
10781061
"lastProbeTime": {
1079-
"$ref": "#/definitions/DateTime"
1062+
"format": "date-time",
1063+
"type": "string"
10801064
},
10811065
"status": {
10821066
"type": "string"
@@ -1217,7 +1201,8 @@
12171201
"minimum": 0.0
12181202
},
12191203
"startTime": {
1220-
"$ref": "#/definitions/DateTime"
1204+
"format": "date-time",
1205+
"type": "string"
12211206
},
12221207
"conditions": {
12231208
"type": "array",
@@ -1312,7 +1297,8 @@
13121297
"type": "string"
13131298
},
13141299
"activationTime": {
1315-
"$ref": "#/definitions/DateTime"
1300+
"format": "date-time",
1301+
"type": "string"
13161302
},
13171303
"subsystems": {
13181304
"type": "array",
@@ -1925,7 +1911,8 @@
19251911
"type": "string"
19261912
},
19271913
"deletionTimestamp": {
1928-
"$ref": "#/definitions/DateTime"
1914+
"format": "date-time",
1915+
"type": "string"
19291916
},
19301917
"labels": {
19311918
"$ref": "#/definitions/Map"
@@ -1952,7 +1939,8 @@
19521939
"type": "string"
19531940
},
19541941
"creationTimestamp": {
1955-
"$ref": "#/definitions/DateTime"
1942+
"format": "date-time",
1943+
"type": "string"
19561944
},
19571945
"name": {
19581946
"type": "string"

json-schema/src/main/java/oracle/kubernetes/json/SchemaGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.net.URL;
1919
import java.util.*;
2020
import javax.annotation.Nonnull;
21+
import org.joda.time.DateTime;
2122

2223
@SuppressWarnings("WeakerAccess")
2324
public class SchemaGenerator {
@@ -200,6 +201,7 @@ private Object getSubSchema(Field field) {
200201
String description = getDescription(field);
201202
if (description != null) result.put("description", description);
202203
if (isString(field.getType())) addStringRestrictions(result, field);
204+
if (isDateTime(field.getType())) result.put("format", "date-time");
203205
if (isNumeric(field.getType())) addRange(result, field);
204206

205207
return result;
@@ -209,6 +211,10 @@ private boolean isString(Class<?> type) {
209211
return type.equals(String.class);
210212
}
211213

214+
private boolean isDateTime(Class<?> type) {
215+
return type.equals(DateTime.class);
216+
}
217+
212218
private boolean isNumeric(Class<?> type) {
213219
return Number.class.isAssignableFrom(type) || PRIMITIVE_NUMBERS.contains(type);
214220
}
@@ -265,7 +271,7 @@ private class SubSchemaGenerator {
265271
private void generateTypeIn(Map<String, Object> result, Class<?> type) {
266272
if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) result.put("type", "boolean");
267273
else if (isNumeric(type)) result.put("type", "number");
268-
else if (isString(type)) result.put("type", "string");
274+
else if (isString(type) || isDateTime(type)) result.put("type", "string");
269275
else if (type.isEnum()) generateEnumTypeIn(result, (Class<? extends Enum>) type);
270276
else if (type.isArray()) this.generateArrayTypeIn(result, type);
271277
else if (Collection.class.isAssignableFrom(type)) generateCollectionTypeIn(result);

0 commit comments

Comments
 (0)