diff --git a/integration-tests/src/test/java/io/apicurio/tests/serdes/confluent/BasicConfluentSerDesIT.java b/integration-tests/src/test/java/io/apicurio/tests/serdes/confluent/BasicConfluentSerDesIT.java index 780ffd4414..48df817499 100644 --- a/integration-tests/src/test/java/io/apicurio/tests/serdes/confluent/BasicConfluentSerDesIT.java +++ b/integration-tests/src/test/java/io/apicurio/tests/serdes/confluent/BasicConfluentSerDesIT.java @@ -135,7 +135,6 @@ void testAvroApicurioConfluent() throws Exception { //very important .withProducerProperty(SerdeConfig.ENABLE_HEADERS, "false") - .withProducerProperty(SerdeConfig.ENABLE_CONFLUENT_ID_HANDLER, "true") .withProducerProperty(SerdeConfig.USE_ID, IdOption.contentId.name()) .withDeserializer(KafkaAvroDeserializer.class) diff --git a/schema-util/util-provider/src/test/java/io/apicurio/registry/content/dereference/JsonSchemaContentDereferencerTest.java b/schema-util/util-provider/src/test/java/io/apicurio/registry/content/dereference/JsonSchemaContentDereferencerTest.java index 0d4d201438..ac84deff77 100644 --- a/schema-util/util-provider/src/test/java/io/apicurio/registry/content/dereference/JsonSchemaContentDereferencerTest.java +++ b/schema-util/util-provider/src/test/java/io/apicurio/registry/content/dereference/JsonSchemaContentDereferencerTest.java @@ -50,8 +50,8 @@ public void testRewriteReferences() { } @Test - public void testDereference() { - ContentHandle content = resourceToContentHandle("json-schema-to-deref.json"); + public void testDereferenceObjectLevel() { + ContentHandle content = resourceToContentHandle("json-schema-to-deref-object-level.json"); JsonSchemaDereferencer dereferencer = new JsonSchemaDereferencer(); // Note: order is important. The JSON schema dereferencer needs to convert the ContentHandle Map // to a JSONSchema map. So it *must* resolve the leaves of the dependency tree before the branches. @@ -62,8 +62,24 @@ public void testDereference() { resolvedReferences.put("types/all-types.json#/definitions/City", resourceToContentHandle("types/all-types.json")); resolvedReferences.put("types/all-types.json#/definitions/Identifier", resourceToContentHandle("types/all-types.json")); ContentHandle modifiedContent = dereferencer.dereference(content, resolvedReferences); - String expectedContent = resourceToString("expected-testDereference-json.json"); + String expectedContent = resourceToString("expected-testDereference-object-level-json.json"); Assertions.assertEquals(normalizeMultiLineString(expectedContent), normalizeMultiLineString(modifiedContent.content())); } + @Test + public void testDereferencePropertyLevel() { + ContentHandle content = resourceToContentHandle("json-schema-to-deref-property-level.json"); + JsonSchemaDereferencer dereferencer = new JsonSchemaDereferencer(); + // Note: order is important. The JSON schema dereferencer needs to convert the ContentHandle Map + // to a JSONSchema map. So it *must* resolve the leaves of the dependency tree before the branches. + Map resolvedReferences = new LinkedHashMap<>(); + resolvedReferences.put("types/city/qualification.json", resourceToContentHandle("types/city/qualification.json")); + resolvedReferences.put("city/qualification.json", resourceToContentHandle("types/city/qualification.json")); + resolvedReferences.put("identifier/qualification.json", resourceToContentHandle("types/identifier/qualification.json")); + resolvedReferences.put("types/all-types.json#/definitions/City/properties/name", resourceToContentHandle("types/all-types.json")); + resolvedReferences.put("types/all-types.json#/definitions/Identifier", resourceToContentHandle("types/all-types.json")); + ContentHandle modifiedContent = dereferencer.dereference(content, resolvedReferences); + String expectedContent = resourceToString("expected-testDereference-property-level-json.json"); + Assertions.assertEquals(normalizeMultiLineString(expectedContent), normalizeMultiLineString(modifiedContent.content())); + } } diff --git a/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-json.json b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-object-level-json.json similarity index 100% rename from schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-json.json rename to schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-object-level-json.json diff --git a/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-property-level-json.json b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-property-level-json.json new file mode 100644 index 0000000000..3c377c985d --- /dev/null +++ b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/expected-testDereference-property-level-json.json @@ -0,0 +1,70 @@ +{ + "$schema" : "http://json-schema.org/draft-07/schema#", + "title" : "Citizen", + "type" : "object", + "properties" : { + "firstName" : { + "description" : "The citizen's first name.", + "type" : "string" + }, + "lastName" : { + "description" : "The citizen's last name.", + "type" : "string" + }, + "identifier" : { + "title" : "Identifier", + "type" : "object", + "properties" : { + "identifier" : { + "description" : "The citizen identifier.", + "type" : "integer", + "minimum" : 0 + }, + "qualification" : { + "title" : "Qualification", + "type" : "object", + "properties" : { + "qualification" : { + "description" : "The identifier qualification", + "type" : "integer", + "minimum" : 20 + }, + "name" : { + "description" : "The subject's name", + "type" : "string" + } + } + } + } + }, + "qualifications" : { + "type" : "array", + "items" : { + "title" : "Qualification", + "type" : "object", + "properties" : { + "qualification" : { + "description" : "The city qualification", + "type" : "integer", + "minimum" : 10 + }, + "name" : { + "description" : "The subject's name", + "type" : "string" + } + } + } + }, + "city" : { + "description" : "The city's name.", + "type" : "string" + }, + "age" : { + "description" : "Age in years which must be equal to or greater than zero.", + "type" : "integer", + "minimum" : 0 + } + }, + "required" : [ "city" ], + "$id" : "https://example.com/citizen.json" +} diff --git a/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref.json b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref-object-level.json similarity index 100% rename from schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref.json rename to schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref-object-level.json diff --git a/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref-property-level.json b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref-property-level.json new file mode 100644 index 0000000000..237ca3e140 --- /dev/null +++ b/schema-util/util-provider/src/test/resources/io/apicurio/registry/content/dereference/json-schema-to-deref-property-level.json @@ -0,0 +1,36 @@ +{ + "$id": "https://example.com/citizen.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Citizen", + "type": "object", + "properties": { + "firstName": { + "type": "string", + "description": "The citizen's first name." + }, + "lastName": { + "type": "string", + "description": "The citizen's last name." + }, + "age": { + "description": "Age in years which must be equal to or greater than zero.", + "type": "integer", + "minimum": 0 + }, + "city": { + "$ref": "types/all-types.json#/definitions/City/properties/name" + }, + "identifier": { + "$ref": "types/all-types.json#/definitions/Identifier" + }, + "qualifications": { + "type": "array", + "items": { + "$ref": "types/city/qualification.json" + } + } + }, + "required": [ + "city" + ] +} \ No newline at end of file