protected JsonSchema findJsonSchema(final PropertyContext<?> cs) { final String[] segments = cs.getProperty().getPath().split("\\."); JsonSchema schema = jsonSchema; for (final String current : segments) { if (current.endsWith("[]")) { schema = schema.getProperties().get(current.substring(0, current.length() - "[]".length())).getItems(); } else { schema = schema.getProperties().get(current); } if (schema != null && "array".equals(schema.getType()) && schema.getItems() != null) { schema = schema.getItems(); } if (schema == null) { // unexpected log.warn("Didn't find json schema for {}", cs.getProperty().getPath()); return null; } } return schema; } }
@Override public CompletionStage<PropertyContext<?>> convert(final CompletionStage<PropertyContext<?>> cs) { return cs.thenCompose(context -> { final UiSchema schema = newUiSchema(context); setupUiSchema(context, schema); final JsonSchema jsonSchema = findJsonSchema(context); if (jsonSchema == null) { // unexpected return CompletableFuture.completedFuture(context); } if (jsonSchema.getType() == null) { jsonSchema.setType("string"); } return fillProposalsAndReturn(context, schema, jsonSchema); }); }
@Override public CompletionStage<PropertyContext<?>> convert(final CompletionStage<PropertyContext<?>> cs) { return cs.thenCompose(context -> { final UiSchema schema = newUiSchema(context); schema.setWidget("datalist"); schema.setTitleMap(emptyList()); final JsonSchema jsonSchema = findJsonSchema(context); if (jsonSchema != null) { if (jsonSchema.getType() == null) { jsonSchema.setType("string"); } // avoid to validate against the enum since we don't udpate it at suggestion time jsonSchema.setEnumValues(null); } return CompletableFuture.completedFuture(context); }); } }
if (jsonSchema.getType() == null) { jsonSchema.setType("string");