Configuring custom artifact types
In addition to the built-in artifact types, Apicurio Registry can be configured at deployment time with custom artifact types. The behavior of a custom type (content detection, validation, compatibility checking, canonicalization, dereferencing) is provided either by webhooks or by Java classes. This chapter describes the configuration file and how to add Java providers to the container image without rebuilding Apicurio Registry.
Artifact type configuration file
The list of artifact types supported by a Apicurio Registry instance is read from a JSON file at startup. The file is configured with the apicurio.artifact-types.config-file property (environment variable APICURIO_ARTIFACT_TYPES_CONFIG_FILE). 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 (AVRO, JSON, OPENAPI, …) remain available. When |
|
The list of custom artifact types. |
| Property | Description |
|---|---|
|
The identifier of the type, used in the REST API and the UI (for example |
|
Display name and description of the type. |
|
The content types (media types) accepted for this artifact type. |
|
Provider that decides whether a piece of content belongs to this type. Used to detect the artifact type when a client does not specify one. |
|
Provider that backs the |
|
Provider that backs the |
|
Provider that produces the canonical form of the content, used to recognize equivalent content (for example canonical search and de-duplication). |
|
Provider that inlines or rewrites references to other artifacts when content is retrieved with |
|
Provider that finds external references in the content. Used by the Maven plug-in to register references automatically. |
Every provider property is optional. When a provider is not configured, the corresponding feature is a no-op for the type (for example, the artifact type is never auto-detected and every content is considered valid and compatible).
| Provider | Description |
|---|---|
|
A Java class implementing the corresponding interface of the |
|
An HTTP endpoint that Apicurio Registry calls with a JSON request describing the operation (content, resolved references, rule level) and that returns a JSON response. The optional |
Adding Java providers with the mutable container image
The standard Apicurio Registry container image is a Quarkus fast-jar: its class path is indexed when the image is built, so a jar copied into the image is not visible to the application. Every release is therefore also published as a VERSION-mutable image, a Quarkus mutable-jar that can be re-augmented to include additional jars. Build a derived image that copies your provider jar into the providers directory and runs the re-augmentation once, at image build time.
-
A jar containing your provider classes, compiled against the
io.apicurio:apicurio-registry-schema-util-commonmodule of the same Apicurio Registry minor version. The jar must not bundle the Apicurio Registry or Quarkus classes; other dependencies must either be already present in the image or be copied into the providers directory as well. -
An artifact type configuration file, see Artifact type configuration file.
-
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.json/deployments/build.shre-augments the application with the jars found in/deployments/quarkus-app/providersand adds only the regenerated class-path index (a few MB) to the derived image. The--pruneoption removes thelib/deploymentdirectory (the Quarkus deployment jars) from the file system of the derived image afterwards; omit it if you want to re-augment the derived image again later. -
Build and run the image:
$ docker build -t my-registry . $ docker run -it -p 8080:8080 my-registry -
Verify that the custom type is available:
$ curl http://localhost:8080/apis/registry/v3/admin/config/artifactTypes
Re-augmentation takes about ten seconds and requires roughly 1 GB of memory during the image build (tune it with the JAVA_OPTS_APPEND environment variable). It must be repeated, by rebuilding the derived image, whenever the provider jars change. The startup time and runtime behavior of Apicurio Registry are not affected.
| Standard image | -mutable image |
|
|---|---|---|
Packaging |
Quarkus fast-jar ( |
Quarkus mutable-jar ( |
Size |
Reference |
About 47 MB (150 jars) of additional files in |
Java providers |
Not supported (use webhooks) |
Supported through |
Runtime behavior |
Reference |
Identical |
-
Custom artifact types example (a complete
MARKDOWNartifact type with Java providers)
