Skip to content

Commit

Permalink
Add manual example for json schema refs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlesarnal committed Nov 13, 2024
1 parent 6cfa0de commit a89a31e
Show file tree
Hide file tree
Showing 15 changed files with 991 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ This section shows a simple example of using the Maven plug-in to register an Av
<file>
${project.basedir}/src/main/resources/schemas/TradeKey.avsc <5>
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<autoRefs>true</autoRefs> <6>
</artifact>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ This example then creates a `TradeKey` schema artifact, which includes a referen
<file>
${project.basedir}/src/main/resources/schemas/TradeKey.avsc
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<references>
<reference> <5>
Expand All @@ -96,7 +96,7 @@ This example then creates a `TradeKey` schema artifact, which includes a referen
<file>
${project.basedir}/src/main/resources/schemas/Exchange.avsc
</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
</reference>
</references>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The most common use case for the Maven plug-in is adding artifacts during a buil
<artifactId>ExampleAPI</artifactId> <5>
<type>GRAPHQL</type>
<file>${project.basedir}/src/main/resources/apis/example.graphql</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
</artifact>
</artifacts>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif::[]
<artifactId>ExampleAPI</artifactId> <4>
<type>GRAPHQL</type>
<file>${project.basedir}/src/main/resources/apis/example.graphql</file>
<ifExists>RETURN_OR_UPDATE</ifExists>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
</artifact>
</artifacts>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
132 changes: 132 additions & 0 deletions examples/json-maven-with-references/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-examples</artifactId>
<version>3.0.4-SNAPSHOT</version>
</parent>

<artifactId>apicurio-registry-examples-json-maven-with-references</artifactId>
<packaging>jar</packaging>

<properties>
<projectRoot>${project.basedir}/../..</projectRoot>
</properties>

<build>
<plugins>
<plugin>
<groupId>io.apicurio</groupId>
<artifactId>apicurio-registry-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>register-artifact</id>
<goals>
<goal>register</goal>
</goals>
<phase>process-test-resources</phase>
<configuration>
<registryUrl>http://localhost:8080/apis/registry/v3</registryUrl>
<artifacts>
<artifact>
<groupId>json-maven-with-references</groupId>
<artifactId>stockAdjustment</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/out/jsd/FLIStockAdjustment.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<references>
<reference>
<name>../../common/jsd/FLIServiceTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIServiceTypes</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/common/jsd/FLIServiceTypes.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
</reference>
<reference>
<name>../../common/jsd/FLIStockTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIStockTypes</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/common/jsd/FLIStockTypes.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<references>
<reference>
<name>../../common/jsd/FLIItemBaseTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIItemBaseTypes</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/common/jsd/FLIItemBaseTypes.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<references>
<reference>
<name>../../common/jsd/FLIBusinessUnitBaseTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIBusinessUnitBaseTypes</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/common/jsd/FLIBusinessUnitBaseTypes.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
<references>
<reference>
<name>../../common/jsd/FLIServiceTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIServiceTypes</artifactId>
<version>1.0.0</version>
</reference>
</references>
</reference>
</references>
</reference>
<reference>
<name>../../common/jsd/FLIBusinessUnitBaseTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIBusinessUnitBaseTypes</artifactId>
<version>1.0.0</version>
</reference>
<reference>
<name>../../common/jsd/FLIServiceTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIServiceTypes</artifactId>
<version>1.0.0</version>
</reference>
</references>
</reference>
<reference>
<name>../../common/jsd/FLIBusinessUnitBaseTypes.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>FLIBusinessUnitBaseTypes</artifactId>
<version>1.0.0</version>
</reference>
<reference>
<name>../../common/jsd/FLIMessageHeader.json</name>
<groupId>json-maven-with-references</groupId>
<artifactId>MsgHeaderType</artifactId>
<version>1.0.0</version>
<artifactType>JSON</artifactType>
<file>${project.basedir}/src/main/resources/schemas/common/jsd/FLIMessageHeader.json</file>
<ifExists>FIND_OR_CREATE_VERSION</ifExists>
<canonicalize>true</canonicalize>
</reference>
</references>
</artifact>
</artifacts>
<existingReferences/>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Original file line number Diff line number Diff line change
@@ -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" }
]
}
Loading

0 comments on commit a89a31e

Please sign in to comment.