Skip to content

Commit 239d4c2

Browse files
Merge branch '8.1.x' into master by rayokota
2 parents 9efd13c + 9d1e077 commit 239d4c2

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

json-schema-provider/src/main/java/io/confluent/kafka/schemaregistry/json/JsonSchema.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,16 @@ public String canonicalString() {
536536
return canonicalString;
537537
}
538538

539+
@Override
540+
public String formattedString(String format) {
541+
if (format == null || format.trim().isEmpty()) {
542+
return canonicalString();
543+
}
544+
// Don't throw an exception for forward compatibility of formats
545+
log.warn("Unsupported format {}", format);
546+
return canonicalString();
547+
}
548+
539549
@Override
540550
public Integer version() {
541551
return version;

json-schema-provider/src/test/java/io/confluent/kafka/schemaregistry/json/JsonSchemaTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,28 @@ public void testAddTagToCompositeField() {
12571257
assertEquals(ImmutableSet.of("PII", "TEST2", "TEST3"), resultSchema.inlineTags());
12581258
}
12591259

1260+
@Test
1261+
public void testBadFormat() throws Exception {
1262+
String schema = "{\n"
1263+
+ " \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n"
1264+
+ " \"$id\": \"task.schema.json\",\n"
1265+
+ " \"title\": \"Task\",\n"
1266+
+ " \"description\": \"A task\",\n"
1267+
+ " \"type\": [\"null\", \"object\"],\n"
1268+
+ " \"properties\": {\n"
1269+
+ " \"parent\": {\n"
1270+
+ " \"$ref\": \"task.schema.json\"\n"
1271+
+ " }, \n"
1272+
+ " \"title\": {\n"
1273+
+ " \"description\": \"Task title\",\n"
1274+
+ " \"type\": \"string\"\n"
1275+
+ " }\n"
1276+
+ " }\n"
1277+
+ "}";
1278+
JsonSchema jsonSchema = new JsonSchema(schema);
1279+
assertEquals(jsonSchema.canonicalString(), jsonSchema.formattedString("serialized"));
1280+
}
1281+
12601282
@Test
12611283
public void testRestrictedFields() {
12621284
String schema = "{\n"

0 commit comments

Comments
 (0)