Configuring custom artifact types
You can configure Apicurio Registry with custom artifact types at deployment time, in addition to the built-in types. Webhooks or Java classes provide content detection, validation, compatibility checking, canonicalization, and dereferencing for each custom type. You can add Java providers to a derived container image without rebuilding Apicurio Registry.
Artifact type configuration file
At startup, Apicurio Registry reads the list of supported artifact types from a JSON file.
The apicurio.artifact-types.config-file property specifies the file location, with APICURIO_ARTIFACT_TYPES_CONFIG_FILE as the corresponding environment variable.
When the file does not exist, only the built-in artifact types are available.
{
"includeStandardArtifactTypes": true,
"artifactTypes": [
{
"artifactType": "MARKDOWN",
"name": "Markdown",
"description": "Markdown documents with a level-1 title and level-2 sections.",
"contentTypes": ["text/markdown", "text/plain"],
"contentAccepter": {
"type": "java",
"classname": "io.apicurio.registry.examples.customtypes.MarkdownContentAccepter"
},
"contentValidator": {
"type": "java",
"classname": "io.apicurio.registry.examples.customtypes.MarkdownContentValidator"
},
"compatibilityChecker": {
"type": "webhook",
"url": "https://markdown-service.example.com/compatibility",
"headers": { "Authorization": "Bearer YOUR_SECRET_TOKEN" }
}
}
]
}
| Property | Description |
|---|---|
|
Whether the built-in artifact types, such as |
|
The list of custom artifact types. |
| Property | Description |
|---|---|
|
The unique identifier of the type, such as |
|
Display name and description of the type. |
|
The content types (media types) accepted for this artifact type. |
|
Provider that determines whether content belongs to this type. Apicurio Registry uses this provider to detect the artifact type when a client does not specify one. |
|
Provider that implements the |
|
Provider that implements the |
|
Provider that produces the canonical form of the content. Apicurio Registry uses this form to recognize equivalent content, for example, in canonical search and deduplication. |
|
Provider that inlines or rewrites references to other artifacts when content is retrieved with |
|
Provider that finds external references in the content. The Maven plug-in uses this provider to register references automatically. |
Every provider property is optional.
When you omit a provider, Apicurio Registry skips the corresponding operation for the type.
For example, without a contentAccepter, Apicurio Registry does not detect the type automatically.
Without a contentValidator, Apicurio Registry treats all content as valid.
Without a compatibilityChecker, Apicurio Registry treats all content as compatible.
| Provider | Description |
|---|---|
|
A Java class that implements the corresponding interface of the |
|
An HTTP endpoint that Apicurio Registry calls with a JSON request that describes the operation, including the content, resolved references, and rule level. The endpoint returns a JSON response.
Apicurio Registry sends the optional |
Container images for custom artifact types
The standard Apicurio Registry container image supports webhook providers.
The VERSION-mutable image variant also supports Java providers by using Quarkus re-augmentation, which updates the application class path to include additional Java archive (JAR) files.
The standard image uses Quarkus fast-jar packaging, which indexes the class path when the image is built.
The application cannot load a JAR file that you copy into the image after that indexing step.
Each Apicurio Registry release also provides a VERSION-mutable image with Quarkus mutable-jar packaging for re-augmentation.
| Characteristic | Standard image | -mutable image |
|---|---|---|
Packaging |
Quarkus fast-jar ( |
Quarkus mutable-jar ( |
Size |
Baseline |
Approximately 47 MB (150 JAR files) of additional files in |
Java providers |
Not supported; webhook providers are available |
Supported by |
Runtime behavior |
Baseline |
Same runtime behavior and startup time as the standard image |
Adding Java providers with the mutable container image
You can add custom Java providers to Apicurio Registry by building a derived container image from the VERSION-mutable image.
The derived image includes your provider Java archive (JAR) file and runs Quarkus re-augmentation at image build time to add the providers to the application class path.
-
You have a JAR file containing your provider classes, compiled against the
io.apicurio:apicurio-registry-schema-util-commonmodule of the same Apicurio Registry minor version. The JAR file must not bundle the Apicurio Registry or Quarkus classes. Other dependencies must be available in the image or in the providers directory. -
You have an artifact type configuration file as described in Artifact type configuration file.
-
You have Docker and
curlinstalled.
-
Create a
Dockerfilethat derives from the mutable image:FROM apicurio/apicurio-registry:latest-release-mutable COPY --chown=1001:0 my-artifact-type.jar /deployments/quarkus-app/providers/ COPY --chown=1001:0 artifact-types.json /deployments/artifact-types.json RUN /deployments/build.sh --prune ENV APICURIO_ARTIFACT_TYPES_CONFIG_FILE=/deployments/artifact-types.jsonThe
/deployments/build.shscript re-augments the application with the JAR files in/deployments/quarkus-app/providers. It adds only the regenerated class-path index, a few MB in size, to the derived image. The--pruneoption removes thelib/deploymentdirectory, which contains the Quarkus deployment JAR files, from the file system afterward. Omit--pruneif you want to re-augment the derived image again later. -
Build the image:
$ docker build -t my-registry .Re-augmentation takes approximately 10 seconds and requires roughly 1 GB of memory during the image build. You can adjust the memory settings with the
JAVA_OPTS_APPENDenvironment variable. Rebuild the derived image whenever the provider JAR files change. Re-augmentation does not change the startup time or runtime behavior of Apicurio Registry. -
Run the image:
$ docker run -it -p 8080:8080 my-registry
-
In another terminal, list the available artifact types:
$ curl http://localhost:8080/apis/registry/v3/admin/config/artifactTypesVerify that the response includes the name of your custom artifact type.
