mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
fix(build): resolve the JSON schema library from Maven Central (#2811)
A clone with a cold ~/.m2 cannot build. Apicurio's schema-util-json asks for the JSON schema library under its JitPack coordinate, com.github.everit-org.json-schema:org.everit.json.schema, which has never been published to Maven Central. The project declares no repositories, so Maven only ever consults Central, where that artifact returns 404. Builds that work are resolving it from a warm local cache, CI included via its restored Maven cache, which is why this stayed hidden. Replaced with com.github.erosb:everit-json-schema, the same project rehomed by its author to a Central-published coordinate. Both jars carry the same 174 classes under org.everit.json.schema, so apicurio's JsonSchemaCompatibilityChecker and JsonSchemaContentValidator load unchanged, and the Central version is newer (1.14.6 against 1.14.4). Adds the JSON cases that prove it. SchemaCompatibilityCheckerTest covered only AVRO and PROTOBUF, neither of which touches the library, so the whole JSON branch of checkerFor/validatorFor was untested and a missing dependency would only have surfaced at runtime. Dropping the replacement now fails those three with NoClassDefFoundError on org.everit.json.schema.loader.SchemaLoader. One expectation is asserted as observed rather than assumed: apicurio treats adding an optional JSON property as narrowing, the opposite of the AVRO case, because data carrying that key with another type validated before.
This commit is contained in:
1 parent
2d724d15aa
commit
66d910c613
2 files changed
+68
No files matched your search
@@ -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>
|
||||
|
||||
+50
@@ -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\"]}";
|
||||
|
||||
@Test
|
||||
void 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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user