@SuppressWarnings("unchecked")
private static Document innerJsonSchema(Document full) {
// full is { "$jsonSchema": { ... } }
return (Document) full.get("$jsonSchema");
}
private static Document mergeSchemasAsOneOf(Document... fullSchemas) {
List<Document> versions = new ArrayList<>();
for (Document full : fullSchemas) {
versions.add(innerJsonSchema(full));
}
return new Document("$jsonSchema", new Document("oneOf", versions));
}
// If you prefer "anyOf":
private static Document mergeSchemasAsAnyOf(Document... fullSchemas) {
List<Document> versions = new ArrayList<>();
for (Document full : fullSchemas) {
versions.add(innerJsonSchema(full));
}
return new Document("$jsonSchema", new Document("anyOf", versions));
}
Intelligence View
SOCIAL SHARE CARD GENERATOR