diff --git a/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-automatically-using-maven-plugin.adoc b/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-automatically-using-maven-plugin.adoc index 70767fb11d..3be84dceb5 100644 --- a/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-automatically-using-maven-plugin.adoc +++ b/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-automatically-using-maven-plugin.adoc @@ -93,7 +93,7 @@ This section shows a simple example of using the Maven plug-in to register an Av ${project.basedir}/src/main/resources/schemas/TradeKey.avsc <5> - RETURN_OR_UPDATE + FIND_OR_CREATE_VERSION true true <6> diff --git a/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-manually-using-maven-plugin.adoc b/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-manually-using-maven-plugin.adoc index 4ba2078d50..c34fda9a12 100644 --- a/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-manually-using-maven-plugin.adoc +++ b/docs/modules/ROOT/partials/getting-started/proc-adding-artifact-references-manually-using-maven-plugin.adoc @@ -84,7 +84,7 @@ This example then creates a `TradeKey` schema artifact, which includes a referen ${project.basedir}/src/main/resources/schemas/TradeKey.avsc - RETURN_OR_UPDATE + FIND_OR_CREATE_VERSION true <5> @@ -96,7 +96,7 @@ This example then creates a `TradeKey` schema artifact, which includes a referen ${project.basedir}/src/main/resources/schemas/Exchange.avsc - RETURN_OR_UPDATE + FIND_OR_CREATE_VERSION true diff --git a/docs/modules/ROOT/partials/getting-started/proc-adding-artifacts-using-maven-plugin.adoc b/docs/modules/ROOT/partials/getting-started/proc-adding-artifacts-using-maven-plugin.adoc index 71ae02ecfd..5a92e11088 100644 --- a/docs/modules/ROOT/partials/getting-started/proc-adding-artifacts-using-maven-plugin.adoc +++ b/docs/modules/ROOT/partials/getting-started/proc-adding-artifacts-using-maven-plugin.adoc @@ -43,7 +43,7 @@ The most common use case for the Maven plug-in is adding artifacts during a buil ExampleAPI <5> GRAPHQL ${project.basedir}/src/main/resources/apis/example.graphql - RETURN_OR_UPDATE + FIND_OR_CREATE_VERSION true diff --git a/docs/modules/ROOT/partials/getting-started/proc-registry-serdes-register.adoc b/docs/modules/ROOT/partials/getting-started/proc-registry-serdes-register.adoc index 6a9a1af3ed..ef2f13f278 100644 --- a/docs/modules/ROOT/partials/getting-started/proc-registry-serdes-register.adoc +++ b/docs/modules/ROOT/partials/getting-started/proc-registry-serdes-register.adoc @@ -76,7 +76,7 @@ endif::[] ExampleAPI <4> GRAPHQL ${project.basedir}/src/main/resources/apis/example.graphql - RETURN_OR_UPDATE + FIND_OR_CREATE_VERSION true diff --git a/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc b/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc index 82679453f9..f577ec0606 100644 --- a/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc +++ b/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc @@ -709,6 +709,11 @@ The following {registry} configuration options are available for each component | | |Kafka sql storage bootstrap servers +|`apicurio.kafkasql.consumer.group-prefix` +|`string` +|`apicurio-` +| +|Kafka sql storage prefix for consumer group name |`apicurio.kafkasql.consumer.poll.timeout` |`integer` |`5000` diff --git a/examples/json-maven-with-references/pom.xml b/examples/json-maven-with-references/pom.xml new file mode 100644 index 0000000000..d6842055c0 --- /dev/null +++ b/examples/json-maven-with-references/pom.xml @@ -0,0 +1,132 @@ + + + 4.0.0 + + io.apicurio + apicurio-registry-examples + 3.0.4-SNAPSHOT + + + apicurio-registry-examples-json-maven-with-references + jar + + + ${project.basedir}/../.. + + + + + + io.apicurio + apicurio-registry-maven-plugin + ${project.version} + + + register-artifact + + register + + process-test-resources + + http://localhost:8080/apis/registry/v3 + + + json-maven-with-references + stockAdjustment + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/out/jsd/FLIStockAdjustment.json + FIND_OR_CREATE_VERSION + true + + + ../../common/jsd/FLIServiceTypes.json + json-maven-with-references + FLIServiceTypes + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/common/jsd/FLIServiceTypes.json + FIND_OR_CREATE_VERSION + true + + + ../../common/jsd/FLIStockTypes.json + json-maven-with-references + FLIStockTypes + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/common/jsd/FLIStockTypes.json + FIND_OR_CREATE_VERSION + true + + + ../../common/jsd/FLIItemBaseTypes.json + json-maven-with-references + FLIItemBaseTypes + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/common/jsd/FLIItemBaseTypes.json + FIND_OR_CREATE_VERSION + true + + + ../../common/jsd/FLIBusinessUnitBaseTypes.json + json-maven-with-references + FLIBusinessUnitBaseTypes + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/common/jsd/FLIBusinessUnitBaseTypes.json + FIND_OR_CREATE_VERSION + true + + + ../../common/jsd/FLIServiceTypes.json + json-maven-with-references + FLIServiceTypes + 1.0.0 + + + + + + + ../../common/jsd/FLIBusinessUnitBaseTypes.json + json-maven-with-references + FLIBusinessUnitBaseTypes + 1.0.0 + + + ../../common/jsd/FLIServiceTypes.json + json-maven-with-references + FLIServiceTypes + 1.0.0 + + + + + ../../common/jsd/FLIBusinessUnitBaseTypes.json + json-maven-with-references + FLIBusinessUnitBaseTypes + 1.0.0 + + + ../../common/jsd/FLIMessageHeader.json + json-maven-with-references + MsgHeaderType + 1.0.0 + JSON + ${project.basedir}/src/main/resources/schemas/common/jsd/FLIMessageHeader.json + FIND_OR_CREATE_VERSION + true + + + + + + + + + + + + diff --git a/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIBusinessUnitBaseTypes.json b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIBusinessUnitBaseTypes.json new file mode 100644 index 0000000000..c06746e7bb --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIBusinessUnitBaseTypes.json @@ -0,0 +1,59 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIBusinessUnitBaseTypes.json", + "type": "object", + "$defs": { + "buCodeType": { + "type": "string", + "pattern": "(^[0-9A-Z]{3,5})|AP" + }, + "buTypeType": { + "type": "string", + "pattern": "(^[A-Z]{2,3})" + }, + "BusinessUnitReferenceType": { + "type": "object", + "required": [ + "BusinessUnitCode", + "BusinessUnitType" + ], + "properties": { + "BusinessUnitCode": { + "$ref": "#/$defs/buCodeType" + }, + "BusinessUnitType": { + "$ref": "#/$defs/buTypeType" + } + }, + "additionalProperties": false + }, + "BusinessUnitAddressReferenceType": { + "type": "object", + "required": [ + "BusinessUnitCode", + "BusinessUnitType", + "BusinessUnitSequence" + ], + "properties": { + "BusinessUnitCode": { + "$ref": "#/$defs/buCodeType" + }, + "BusinessUnitType": { + "$ref": "#/$defs/buTypeType" + }, + "BusinessUnitSequence": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/positiveInteger4" + } + }, + "additionalProperties": false + } + }, + "anyOf": [ + { + "$ref": "#/$defs/BusinessUnitReferenceType" + }, + { + "$ref": "#/$defs/BusinessUnitAddressReferenceType" + } + ] +} diff --git a/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIItemBaseTypes.json b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIItemBaseTypes.json new file mode 100644 index 0000000000..fe1d9ceb33 --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIItemBaseTypes.json @@ -0,0 +1,68 @@ + +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIItemBaseTypes.json", + "$defs": { + "ItemReferenceType": { + "type": "object", + "properties": { + "ItemNumber": { + "type": "string", + "minLength": 1, + "maxLength": 15 + }, + "ItemType": { + "type": "string", + "enum": [ + "ADS", + "ART", + "CCI", + "HM", + "OAD", + "SGR", + "SPR" + ] + } + }, + "required": [ + "ItemNumber", + "ItemType" + ], + "additionalProperties": false + }, + "ItemSKUType": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "DWPReferenceType": { + "type": "object", + "properties": { + "ItemReference": { + "$ref": "#/$defs/ItemReferenceType" + }, + "ItemSupplierReference": { + "$ref": "../../common/jsd/FLIBusinessUnitBaseTypes.json#/$defs/BusinessUnitReferenceType" + }, + "DWPNumber": { "type": "integer" }, + "DWPEdition": { "type": "integer" }, + "DWPFromPackagingDate": { + "type": "string", + "format": "date" + } + }, + "required": [ + "ItemReference", + "ItemSupplierReference", + "DWPNumber", + "DWPEdition", + "DWPFromPackagingDate" + ], + "additionalProperties": false + } + }, + "anyOf": [ + { "$ref": "#/$defs/ItemReferenceType" }, + { "$ref": "#/$defs/DWPReferenceType" } + ] +} \ No newline at end of file diff --git a/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIMessageHeader.json b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIMessageHeader.json new file mode 100644 index 0000000000..b5bafc391a --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIMessageHeader.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIMessageHeader.json", + "$defs": { + "MsgHeaderType": { + "type": "object", + "properties": { + "MsgName": { + "type": "string", + "minLength": 1, + "maxLength": 36 + }, + "MsgVersNo": { + "type": "string", + "minLength": 1, + "maxLength": 10 + }, + "MsgDateTime": { + "type": "string", + "format": "date-time", + "pattern": "^(.{20})([0-9]{3})[+-]((2[0-3]|[01][0-9])[:]([0-5][0-9]))$" + }, + "MsgReference": { + "type": "string", + "minLength": 1, + "maxLength": 36 + }, + "SendingSystem": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, + "SendingUnit": { + "type": "object", + "properties": { + "BUCode": { + "type": "string", + "minLength": 3, + "maxLength": 5 + }, + "BUType": { + "type": "string", + "minLength": 2, + "maxLength": 3 + } + }, + "required": [ + "BUCode", + "BUType" + ], + "additionalProperties": false + }, + "LogicalRoutingIdentifier": { + "type": "object", + "properties": { + "SourceCode": { + "type": "string", + "minLength": 1 + }, + "SourceType": { + "type": "string", + "minLength": 1 + }, + "SourceLookupType": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "SourceCode", + "SourceType" + ], + "additionalProperties": false + } + }, + "additionalProperties": false, + "required": [ + "MsgName", + "MsgVersNo", + "MsgDateTime", + "MsgReference", + "SendingSystem" + ] + } + }, + "type": "object", + "properties": { + "MsgHeader": { + "$ref": "#/$defs/MsgHeaderType" + } + }, + "required": [ + "MsgHeader" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIServiceTypes.json b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIServiceTypes.json new file mode 100644 index 0000000000..34a7c26754 --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIServiceTypes.json @@ -0,0 +1,308 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIServiceTypes.json", + "$defs": { + "fliDate": { + "type": "string", + "format": "date" + }, + "fliDateTime": { + "type": "string", + "format": "date-time", + "pattern": "^(.{20})([0-9]{3})[+-]((2[0-3]|[01][0-9])[:]([0-5][0-9]))$" + }, + "positiveInteger": { + "type": "integer", + "minimum": 0 + }, + "positiveInteger4": { + "type": "integer", + "minimum": 0, + "maximum": 9999 + }, + "positiveIntegerMax100": { + "type": "integer", + "minimum": 0, + "maximum": 100 + }, + "integer2": { + "type": "integer", + "minimum": -99, + "maximum": 99 + }, + "integer3": { + "type": "integer", + "minimum": -999, + "maximum": 999 + }, + "integer4": { + "type": "integer", + "minimum": -9999, + "maximum": 9999 + }, + "integer6": { + "type": "integer", + "minimum": -999999, + "maximum": 999999 + }, + "integer11": { + "type": "integer", + "minimum": -99999999999, + "maximum": 99999999999 + }, + "decimal7-3": { + "type": "number", + "minimum": -9999.999, + "maximum": 9999.999, + "multipleOf": 0.001 + }, + "decimal9-2": { + "type": "number", + "minimum": -9999999.99, + "maximum": 9999999.99, + "multipleOf": 0.01 + }, + "decimal9-5": { + "type": "number", + "minimum": -9999.99999, + "maximum": 9999.99999, + "multipleOf": 0.00001 + }, + "decimal11-2": { + "type": "number", + "minimum": -999999999.99, + "maximum": 999999999.99, + "multipleOf": 0.01 + }, + "decimal15-5": { + "type": "number", + "minimum": -9999999999.99999, + "maximum": 9999999999.99999, + "multipleOf": 0.00001 + }, + "string1": { + "type": "string", + "maxLength": 1 + }, + "string2": { + "type": "string", + "maxLength": 2 + }, + "string4": { + "type": "string", + "maxLength": 4 + }, + "string8": { + "type": "string", + "maxLength": 8 + }, + "string10": { + "type": "string", + "maxLength": 10 + }, + "string24": { + "type": "string", + "maxLength": 24 + }, + "string35": { + "type": "string", + "maxLength": 35 + }, + "string36": { + "type": "string", + "maxLength": 36 + }, + "string40": { + "type": "string", + "maxLength": 40 + }, + "string50": { + "type": "string", + "maxLength": 50 + }, + "string70": { + "type": "string", + "maxLength": 70 + }, + "string100": { + "type": "string", + "maxLength": 100 + }, + "string160": { + "type": "string", + "maxLength": 160 + }, + "string500": { + "type": "string", + "maxLength": 500 + }, + "nonEmptyString4000": { + "type": "string", + "maxLength": 4000, + "minLength": 1 + }, + "nonEmptyString1000": { + "type": "string", + "maxLength": 1000, + "minLength": 1 + }, + "nonEmptyString500": { + "type": "string", + "maxLength": 500, + "minLength": 1 + }, + "nonEmptyString200": { + "type": "string", + "maxLength": 200, + "minLength": 1 + }, + "nonEmptyString160": { + "type": "string", + "maxLength": 160, + "minLength": 1 + }, + "nonEmptyString150": { + "type": "string", + "maxLength": 150, + "minLength": 1 + }, + "nonEmptyString100": { + "type": "string", + "maxLength": 100, + "minLength": 1 + }, + "nonEmptyString80": { + "type": "string", + "maxLength": 80, + "minLength": 1 + }, + "nonEmptyString70": { + "type": "string", + "maxLength": 70, + "minLength": 1 + }, + "nonEmptyString50": { + "type": "string", + "maxLength": 50, + "minLength": 1 + }, + "nonEmptyString40": { + "type": "string", + "maxLength": 40, + "minLength": 1 + }, + "nonEmptyString36": { + "type": "string", + "maxLength": 36, + "minLength": 1 + }, + "nonEmptyString35": { + "type": "string", + "maxLength": 35, + "minLength": 1 + }, + "nonEmptyString30": { + "type": "string", + "maxLength": 30, + "minLength": 1 + }, + "nonEmptyString25": { + "type": "string", + "maxLength": 25, + "minLength": 1 + }, + "nonEmptyString24": { + "type": "string", + "maxLength": 24, + "minLength": 1 + }, + "nonEmptyString20": { + "type": "string", + "maxLength": 20, + "minLength": 1 + }, + "nonEmptyString18": { + "type": "string", + "maxLength": 18, + "minLength": 1 + }, + "nonEmptyString15": { + "type": "string", + "maxLength": 15, + "minLength": 1 + }, + "nonEmptyString10": { + "type": "string", + "maxLength": 10, + "minLength": 1 + }, + "nonEmptyString8": { + "type": "string", + "maxLength": 8, + "minLength": 1 + }, + "nonEmptyString5": { + "type": "string", + "maxLength": 5, + "minLength": 1 + }, + "nonEmptyString4": { + "type": "string", + "maxLength": 4, + "minLength": 1 + }, + "nonEmptyString3": { + "type": "string", + "maxLength": 3, + "minLength": 1 + }, + "nonEmptyString2": { + "type": "string", + "maxLength": 2, + "minLength": 1 + }, + "nonEmptyString1": { + "type": "string", + "maxLength": 1, + "minLength": 1 + }, + "nonEmptyString": { + "type": "string", + "minLength": 1 + }, + "CountryCodeType": { + "type": "string", + "pattern": "(^[A-Z]{2}$)" + }, + "ServiceResponseType": { + "type": "object", + "properties": { + "ServiceName": { + "$ref": "#/$defs/nonEmptyString100" + }, + "MessageReference": { + "$ref": "#/$defs/nonEmptyString36" + }, + "ReturnCode": { + "$ref": "#/$defs/nonEmptyString4" + }, + "ErrorMessage": { + "$ref": "#/$defs/nonEmptyString100" + }, + "ErrorDetails": { + "$ref": "#/$defs/nonEmptyString500" + } + }, + "required": [ + "ServiceName", + "MessageReference", + "ReturnCode" + ], + "additionalProperties": false + } + }, + "type": "object", + "anyOf": [ + { "$ref": "#/$defs/ServiceResponseType" } + ] +} \ No newline at end of file diff --git a/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIStockTypes.json b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIStockTypes.json new file mode 100644 index 0000000000..2a96918183 --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/common/jsd/FLIStockTypes.json @@ -0,0 +1,178 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIStockTypes.json", + "type": "object", + "$defs": { + "LUStock": { + "description": "This object models the stock object.", + "type": "object", + "properties": { + "ItemReference": { + "$ref": "../../common/jsd/FLIItemBaseTypes.json#/$defs/ItemReferenceType" + }, + "SupplierReference": { + "$ref": "../../common/jsd/FLIBusinessUnitBaseTypes.json#/$defs/BusinessUnitReferenceType" + }, + "ItemDWPReference": { + "$ref": "../../common/jsd/FLIItemBaseTypes.json#/$defs/DWPReferenceType" + }, + "RegistrationDateTime": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/fliDateTime" + }, + "ProductionDate": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/fliDate" + }, + "StockLocationId": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString30" + }, + "Quantity": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/decimal11-2" + }, + "UOMCodeQuantity": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString10" + }, + "InboundConsignmentLineReference": { + "$ref": "#/$defs/ConsignmentLineReference" + }, + "CountryOfOrigin": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/string2" + }, + "TradeStatus": { + "$ref": "#/$defs/TradeStatus" + }, + "OrderReference": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString24" + }, + "OrderType": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString10" + }, + "BondedFlag": { + "type": "boolean" + }, + "LUStockStatus": { + "type": "array", + "items": { + "$ref": "#/$defs/LUStockStatus" + } + } + }, + "required": [ + "ItemReference", + "SupplierReference", + "ItemDWPReference", + "RegistrationDateTime", + "ProductionDate", + "StockLocationId", + "Quantity", + "UOMCodeQuantity", + "CountryOfOrigin", + "TradeStatus", + "BondedFlag" + ], + "additionalProperties": false + }, + "ConsignmentLineReference": { + "type": "object", + "properties": { + "ConsignmentId": { + "$ref": "#/$defs/ConsignmentId" + }, + "ConsignmentLineNumber": { + "$ref": "#/$defs/ConsignmentLineNumber" + } + }, + "required": [ + "ConsignmentId", + "ConsignmentLineNumber" + ], + "additionalProperties": false + }, + "TradeStatus": { + "type": "integer", + "enum": [ + 0, + 1, + 2 + ] + }, + "StockStatusSubCode": { + "type": "integer", + "minimum": 0, + "maximum": 99 + }, + "LUStockStatus": { + "type": "object", + "properties": { + "StockStatus": { + "type": "string" + }, + "StockStatusSubCode": + { + "$ref": "#/$defs/StockStatusSubCode" + } + }, + "required": [ + "StockStatus" + ], + "additionalProperties": false + }, + "ConsignmentId": { + "type": "object", + "properties": { + "CreatorReference": { + "$ref": "../../common/jsd/FLIBusinessUnitBaseTypes.json#/$defs/BusinessUnitReferenceType" + }, + "ConsignmentNumber": { + "type": "string", + "maxLength": 12, + "minLength": 1 + } + }, + "required": [ + "CreatorReference", + "ConsignmentNumber" + ], + "additionalProperties": false + }, + "ConsignmentLineNumber": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/positiveInteger" + }, + "orderSource": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString10" + }, + "executableOrderId": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString40" + }, + "executableOrderLineId": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/integer4" + }, + "OutBoundReferences": { + "type": "object", + "properties": { + "OutboundConsignmentLineReference": { + "$ref": "#/$defs/ConsignmentLineReference" + }, + "OrderSource": { + "$ref": "#/$defs/orderSource" + }, + "ExecutableOrderLineReference": { + "type": "object", + "properties": { + "ExecutableOrderId": { + "$ref": "#/$defs/executableOrderId" + }, + "ExecutableOrderLineId": { + "$ref": "#/$defs/executableOrderLineId" + } + }, + "required": [ + "ExecutableOrderId", + "ExecutableOrderLineId" + ], + "additionalProperties": false + } + }, + "additionalProperties": false + } + } +} diff --git a/examples/json-maven-with-references/src/main/resources/schemas/out/jsd/FLIStockAdjustment.json b/examples/json-maven-with-references/src/main/resources/schemas/out/jsd/FLIStockAdjustment.json new file mode 100644 index 0000000000..0090233520 --- /dev/null +++ b/examples/json-maven-with-references/src/main/resources/schemas/out/jsd/FLIStockAdjustment.json @@ -0,0 +1,100 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "FLIStockAdjustment.json", + "title": "Stock adjustment schema for GIS", + "description": "Schema for the validation of stock adjustment messages.", + "$defs": { + "LUStockAdjustment": { + "type": "object", + "properties": { + "LogId": { + "type": "integer" + }, + "TransactionType": { + "type": "string", + "maxLength": 3 + }, + "ReportDateTime": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/fliDateTime" + }, + "TransactionDateTime": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/fliDateTime" + }, + "AdjustmentQuantity": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/decimal11-2" + }, + "UOMCodeQuantity": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString10" + }, + "ChangeNote": { + "$ref": "../../common/jsd/FLIServiceTypes.json#/$defs/nonEmptyString35" + }, + "OutBoundReferences": { + "$ref": "../../common/jsd/FLIStockTypes.json#/$defs/OutBoundReferences" + }, + "RuleIdentifier": { + "type": "integer" + }, + "SubCode": { + "$ref": "../../common/jsd/FLIStockTypes.json#/$defs/StockStatusSubCode" + } + }, + "required": [ + "LogId", + "TransactionType", + "ReportDateTime", + "TransactionDateTime", + "AdjustmentQuantity", + "UOMCodeQuantity" + ], + "additionalProperties": false + }, + "StockAdjustment": { + "type": "object", + "properties": { + "LogisticUnitReference": { + "$ref": "../../common/jsd/FLIBusinessUnitBaseTypes.json#/$defs/BusinessUnitReferenceType" + }, + "LUStock": { + "$ref": "../../common/jsd/FLIStockTypes.json#/$defs/LUStock" + }, + "LUStockAdjustment": { + "$ref": "#/$defs/LUStockAdjustment" + } + }, + "required": [ + "LogisticUnitReference", + "LUStock", + "LUStockAdjustment" + ], + "additionalProperties": false + } + }, + "type": "object", + "properties": { + "MsgHeader": { + "$ref": "../../common/jsd/FLIMessageHeader.json#/$defs/MsgHeaderType" + }, + "MsgBody": { + "type": "object", + "properties": { + "StockAdjustments": { + "type": "array", + "items": { + "$ref": "#/$defs/StockAdjustment" + }, + "minItems": 1 + } + }, + "required": [ + "StockAdjustments" + ], + "additionalProperties": false + } + }, + "required": [ + "MsgHeader", + "MsgBody" + ], + "additionalProperties": false +} diff --git a/examples/pom.xml b/examples/pom.xml index c0c8c8c60b..4271510a96 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -43,6 +43,7 @@ simple-validation serdes-with-references avro-maven-with-references + json-maven-with-references avro-maven-with-references-auto json-maven-with-references-auto protobuf-validation diff --git a/schema-util/json/src/main/java/io/apicurio/registry/content/dereference/JsonSchemaDereferencer.java b/schema-util/json/src/main/java/io/apicurio/registry/content/dereference/JsonSchemaDereferencer.java index 162689b5a1..613febd698 100644 --- a/schema-util/json/src/main/java/io/apicurio/registry/content/dereference/JsonSchemaDereferencer.java +++ b/schema-util/json/src/main/java/io/apicurio/registry/content/dereference/JsonSchemaDereferencer.java @@ -123,6 +123,16 @@ private void rewriteInObject(ObjectNode node, Map resolvedRefere String $ref = node.get("$ref").asText(); if (resolvedReferenceUrls.containsKey($ref)) { node.put("$ref", resolvedReferenceUrls.get($ref)); + } else { + // The reference in the file might be using just a component, use just the resource for the + // lookup. + JsonPointerExternalReference externalReference = new JsonPointerExternalReference($ref); + if (resolvedReferenceUrls.containsKey(externalReference.getResource())) { + JsonPointerExternalReference rewrittenRef = new JsonPointerExternalReference( + resolvedReferenceUrls.get(externalReference.getResource()), + externalReference.getComponent()); + node.put("$ref", rewrittenRef.getFullReference()); + } } } Iterator fieldNames = node.fieldNames(); diff --git a/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/RegisterRegistryMojo.java b/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/RegisterRegistryMojo.java index 2077294087..c7397f2af8 100644 --- a/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/RegisterRegistryMojo.java +++ b/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/RegisterRegistryMojo.java @@ -11,7 +11,6 @@ import io.apicurio.registry.maven.refs.ReferenceIndex; import io.apicurio.registry.rest.client.models.ArtifactReference; import io.apicurio.registry.rest.client.models.CreateArtifact; -import io.apicurio.registry.rest.client.models.CreateArtifactResponse; import io.apicurio.registry.rest.client.models.CreateVersion; import io.apicurio.registry.rest.client.models.IfArtifactExists; import io.apicurio.registry.rest.client.models.ProblemDetails; @@ -156,10 +155,10 @@ protected void executeInternal() throws MojoExecutionException { registerDirectory(artifact); } else { - List references = new ArrayList<>(); + List references = new ArrayList<>(); // First, we check if the artifact being processed has references defined if (hasReferences(artifact)) { - references = registerArtifactReferences(artifact.getReferences()); + references = processArtifactReferences(artifact.getReferences()); } registerArtifact(artifact, references); } @@ -177,7 +176,7 @@ protected void executeInternal() throws MojoExecutionException { } } - private CreateArtifactResponse registerWithAutoRefs(RegisterArtifact artifact, ReferenceIndex index, + private VersionMetaData registerWithAutoRefs(RegisterArtifact artifact, ReferenceIndex index, Stack registrationStack) throws IOException, ExecutionException, InterruptedException { if (loopDetected(artifact, registrationStack)) { @@ -221,8 +220,7 @@ private CreateArtifactResponse registerWithAutoRefs(RegisterArtifact artifact, R refArtifact.setContentType(getContentTypeByExtension(localFile.getName())); try { var car = registerWithAutoRefs(refArtifact, index, registrationStack); - VersionMetaData amd = car.getVersion(); - iresource.setRegistration(amd); + iresource.setRegistration(car); } catch (IOException | ExecutionException | InterruptedException e) { throw new RuntimeException(e); } @@ -273,13 +271,29 @@ private void registerDirectory(RegisterArtifact artifact) } } - private CreateArtifactResponse registerArtifact(RegisterArtifact artifact, - List references) + private VersionMetaData registerArtifact(RegisterArtifact artifact, List references) throws FileNotFoundException, ExecutionException, InterruptedException { - return registerArtifact(artifact, new FileInputStream(artifact.getFile()), references); + if (artifact.getFile() != null) { + return registerArtifact(artifact, new FileInputStream(artifact.getFile()), references); + } else { + return getArtifactVersionMetadata(artifact); + } + } + + private VersionMetaData getArtifactVersionMetadata(RegisterArtifact artifact) { + String groupId = artifact.getGroupId(); + String artifactId = artifact.getArtifactId(); + String version = artifact.getVersion(); + + VersionMetaData amd = getClient().groups().byGroupId(groupId).artifacts().byArtifactId(artifactId) + .versions().byVersionExpression(version).get(); + getLog().info(String.format("Successfully processed artifact [%s] / [%s]. GlobalId is [%d]", groupId, + artifactId, amd.getGlobalId())); + + return amd; } - private CreateArtifactResponse registerArtifact(RegisterArtifact artifact, InputStream artifactContent, + private VersionMetaData registerArtifact(RegisterArtifact artifact, InputStream artifactContent, List references) throws ExecutionException, InterruptedException { String groupId = artifact.getGroupId(); String artifactId = artifact.getArtifactId(); @@ -334,7 +348,7 @@ private CreateArtifactResponse registerArtifact(RegisterArtifact artifact, Input getLog().info(String.format("Successfully registered artifact [%s] / [%s]. GlobalId is [%d]", groupId, artifactId, vmd.getVersion().getGlobalId())); - return vmd; + return vmd.getVersion(); } catch (ProblemDetails e) { throw new RuntimeException(e.getDetail()); } @@ -344,7 +358,7 @@ private static boolean hasReferences(RegisterArtifact artifact) { return artifact.getReferences() != null && !artifact.getReferences().isEmpty(); } - private List registerArtifactReferences( + private List processArtifactReferences( List referencedArtifacts) throws FileNotFoundException, ExecutionException, InterruptedException { List references = new ArrayList<>(); @@ -353,11 +367,10 @@ private List register // First, we check if the artifact being processed has references defined, and register them if // needed if (hasReferences(artifact)) { - nestedReferences = registerArtifactReferences(artifact.getReferences()); + nestedReferences = processArtifactReferences(artifact.getReferences()); } - CreateArtifactResponse car = registerArtifact(artifact, nestedReferences); - final VersionMetaData metaData = car.getVersion(); - references.add(buildReferenceFromMetadata(metaData, artifact.getName())); + final VersionMetaData artifactMetaData = registerArtifact(artifact, nestedReferences); + references.add(buildReferenceFromMetadata(artifactMetaData, artifact.getName())); } return references; }