Skip to content

Commit 13f08c7

Browse files
jshum2479Johnny Shum
andauthored
Fix missing (#1628)
Co-authored-by: Johnny Shum <[email protected]>
1 parent bec0cb4 commit 13f08c7

File tree

3 files changed

+299
-144
lines changed

3 files changed

+299
-144
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ private boolean isDateTime(Class<?> type) {
237237
return type.equals(DateTime.class);
238238
}
239239

240+
private boolean isMapType(Class<?> type) {
241+
return Map.class.isAssignableFrom(type);
242+
}
243+
240244
private boolean isNumeric(Class<?> type) {
241245
return Number.class.isAssignableFrom(type) || PRIMITIVE_NUMBERS.contains(type);
242246
}
@@ -404,6 +408,13 @@ private void generateObjectTypeIn(Map<String, Object> result, Class<?> type) {
404408
if (isDateTime(type)) {
405409
result.put("type", "string");
406410
result.put("format", "date-time");
411+
} else if (isMapType(type)) {
412+
// reached here if the type is a Map
413+
final Map<String, Object> properties = new HashMap<>();
414+
Optional.ofNullable(getDescription(type)).ifPresent(s -> result.put("description", s));
415+
result.put("type", "object");
416+
properties.put("type", "string");
417+
result.put("additionalProperties", properties);
407418
} else {
408419
final Map<String, Object> properties = new HashMap<>();
409420
List<String> requiredFields = new ArrayList<>();

0 commit comments

Comments
 (0)