Light, fluffy, and always free - The AWS Local Emulator alternative
fix(build): resolve the JSON schema library from Maven Central (#2811)
Hector Ventura66d910c61348
diff --git a/pom.xml b/pom.xmlindex a6f37a9bf1..e881de3dd8 100644--- a/pom.xml+++ b/pom.xml@@ -18,6 +18,7 @@<quarkus.platform.version>3.37.4</quarkus.platform.version><jackson.version>2.22.1</jackson.version><apicurio.version>2.6.13.Final</apicurio.version>+ <everit.json.schema.version>1.14.6</everit.json.schema.version><wire.version>6.4.5</wire.version></properties>@@ -257,8 +258,25 @@<groupId>io.apicurio</groupId><artifactId>apicurio-common-app-components-logging</artifactId></exclusion>+ <!-- Apicurio asks for the JSON schema library under its JitPack coordinate+ (com.github.everit-org.json-schema), which has never been published to Maven+ Central. Resolving it needs a JitPack repository, so a clone with a cold+ ~/.m2 fails to build. Replaced below with the same library under the+ coordinate its author publishes to Central. -->+ <exclusion>+ <groupId>com.github.everit-org.json-schema</groupId>+ <artifactId>org.everit.json.schema</artifactId>+ </exclusion></exclusions></dependency>+ <!-- The same project as com.github.everit-org.json-schema, rehomed by its author to a+ Central-published coordinate: identical org.everit.json.schema packages, so apicurio's+ JsonSchemaCompatibilityChecker and JsonSchemaContentValidator load unchanged. -->+ <dependency>+ <groupId>com.github.erosb</groupId>+ <artifactId>everit-json-schema</artifactId>+ <version>${everit.json.schema.version}</version>+ </dependency><dependency><groupId>io.apicurio</groupId><artifactId>apicurio-registry-schema-util-protobuf</artifactId>diff --git a/src/test/java/io/github/hectorvent/floci/services/glue/schemaregistry/SchemaCompatibilityCheckerTest.java b/src/test/java/io/github/hectorvent/floci/services/glue/schemaregistry/SchemaCompatibilityCheckerTest.javaindex c16454c661..0dd577746c 100644--- a/src/test/java/io/github/hectorvent/floci/services/glue/schemaregistry/SchemaCompatibilityCheckerTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/glue/schemaregistry/SchemaCompatibilityCheckerTest.java@@ -59,6 +59,20 @@ class SchemaCompatibilityCheckerTest {+ " required string phone = 3;\n"+ "}\n";+ private static final String JSON_V1 =+ "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\","+ + "\"properties\":{\"id\":{\"type\":\"integer\"}},\"required\":[\"id\"]}";++ private static final String JSON_ADD_OPTIONAL =+ "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\","+ + "\"properties\":{\"id\":{\"type\":\"integer\"},"+ + "\"email\":{\"type\":\"string\"}},\"required\":[\"id\"]}";++ private static final String JSON_ADD_REQUIRED =+ "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\","+ + "\"properties\":{\"id\":{\"type\":\"integer\"},"+ + "\"email\":{\"type\":\"string\"}},\"required\":[\"id\",\"email\"]}";+@Testvoid noneAlwaysCompatible() {var r = SchemaCompatibilityChecker.check("NONE", List.of(AVRO_V1), AVRO_ADD_REQUIRED, "AVRO");@@ -158,4 +172,40 @@ class SchemaCompatibilityCheckerTest {String error = SchemaCompatibilityChecker.validateDefinition("{garbage", "AVRO");assertNotNull(error);}++ // JSON goes through apicurio's JsonSchemaCompatibilityChecker and JsonSchemaContentValidator,+ // which are backed by the org.everit.json.schema library. These cases are what prove that+ // library actually loads: the AVRO and PROTOBUF paths never touch it, so before this the JSON+ // branch of checkerFor/validatorFor was entirely uncovered.++ @Test+ void jsonBackwardAcceptsAnUnchangedSchema() {+ var r = SchemaCompatibilityChecker.check("BACKWARD", List.of(JSON_V1), JSON_V1, "JSON");+ assertTrue(r.compatible(), () -> "expected compatible, got: " + r.reason());+ }++ /**+ * Apicurio treats adding even an optional property as narrowing, because data that carried that+ * key with another type validated before and no longer does. Asserted as observed rather than+ * assumed: it is the opposite of the AVRO case above.+ */+ @Test+ void jsonBackwardTreatsANewOptionalPropertyAsNarrowing() {+ var r = SchemaCompatibilityChecker.check("BACKWARD", List.of(JSON_V1), JSON_ADD_OPTIONAL, "JSON");+ assertFalse(r.compatible());+ assertNotNull(r.reason());+ }++ @Test+ void jsonBackwardRejectsAddingARequiredProperty() {+ var r = SchemaCompatibilityChecker.check("BACKWARD", List.of(JSON_V1), JSON_ADD_REQUIRED, "JSON");+ assertFalse(r.compatible());+ assertNotNull(r.reason());+ }++ @Test+ void jsonFirstVersionIsCompatible() {+ var r = SchemaCompatibilityChecker.check("BACKWARD", List.of(), JSON_V1, "JSON");+ assertTrue(r.compatible(), () -> "expected compatible, got: " + r.reason());+ }}