@CacheResult(cacheName = "org.talend.sdk.component.proxy.validation.jsonschema") public CompletionStage<JsonSchemaValidator> getValidator(final RequestContext context, final String formId) { return configurations.getDetails(context.language(), formId, context::findPlaceholder).thenCompose(config -> { final JsonSchema jsonSchema = new JsonSchema(); final JsonSchemaConverter converter = new JsonSchemaConverter(jsonb, jsonSchema, config.getProperties()); return CompletableFuture .allOf(config .getProperties() .stream() .filter(Objects::nonNull) .filter(p -> p.getName().equals(p.getPath())) .map(it -> new PropertyContext<>(it, context, LIGHT_CONTEXT_CONFIGURATION)) .map(CompletionStages::toStage) .map(converter::convert) .toArray(CompletableFuture[]::new)) .thenApply(r -> jsonSchema); }).thenApply(schema -> jsonb.fromJson(jsonb.toJson(schema), JsonObject.class)).thenApply(factory::newInstance); } }
ui.setUiSchema(new ArrayList<>()); ui.setProperties(new HashMap<>()); ui.setJsonSchema(new JsonSchema()); ui.getJsonSchema().setTitle(displayName.get()); ui.getJsonSchema().setType("object");
final JsonSchema items = new JsonSchema(); items.setType("object"); items.setProperties(new HashMap<>()); } else if (!arrayElements.isEmpty()) { // primitive final String type = arrayElements.get(0).getType(); final JsonSchema item = new JsonSchema(); item.setTitle(jsonSchema.getTitle()); item.setType("enum".equalsIgnoreCase(type) ? "string" : type.toLowerCase(ROOT));
@Override public CompletionStage<PropertyContext<?>> convert(final CompletionStage<PropertyContext<?>> cs) { return cs.thenCompose(context -> { final JsonSchema jsonSchema = new JsonSchema(); jsonSchema.setTitle(context.getProperty().getDisplayName()); final String type = context.getProperty().getType();
public JsonSchema build() { final JsonSchema jsonSchema = new JsonSchema(); jsonSchema.setId(id); jsonSchema.setTitle(title); jsonSchema.setDescription(description); jsonSchema.setSchema(schema); jsonSchema.setRef(ref); jsonSchema.setType(type); jsonSchema.setMinItems(minItems); jsonSchema.setMaxItems(maxItems); jsonSchema.setMinLength(minLength); jsonSchema.setMaxLength(maxLength); jsonSchema.setMinimum(minimum); jsonSchema.setMaximum(maximum); jsonSchema.setUniqueItems(uniqueItems); jsonSchema.setPattern(pattern); jsonSchema.setDefaultValue(defaultValue); jsonSchema.setRequired(required); jsonSchema.setProperties(properties); jsonSchema.setEnumValues(enumValues); jsonSchema.setItems(items); return jsonSchema; } }