Generating Java Models
FigChain configuration values are Avro records. The FigChain Maven plugin turns your schemas into type-safe Java classes as part of your normal build, so the code that reads a fig is checked by the compiler against the schema it was written for.
The plugin runs in the generate-sources phase, writes the classes to
target/generated-sources/figchain, and adds that directory to the build. There is no separate
artifact to publish or download: every build generates the models from the schemas it names.
Adding the plugin
<build>
<plugins>
<plugin>
<groupId>com.github.figchain.java-client</groupId>
<artifactId>figchain-maven-plugin</artifactId>
<version>v1.4.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemas>
<schema>payments/checkout-settings/3</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>
The generated classes use the Avro runtime, which figchain-client already brings in. See
Installation for the repository settings that make the plugin and client
available to your build.
Choosing schemas
List each schema as namespace/name/version, or by its full schema URI
(tag:figchain.io,2025:payments:checkout-settings:3). Pinning a version keeps builds reproducible:
the generated classes change only when you change the version.
Schemas that a listed schema references are generated too, so you only list the schemas your code uses directly.
Where schemas come from
The plugin reads schemas from one of two sources.
The FigChain API (default)
The plugin calls the FigChain API with a client credential, the same kind your application uses. Keep the credential out of the POM by setting it in the environment of the build:
| Environment variable | Purpose |
|---|---|
FIGCHAIN_URL |
API base URL, for example https://app.figchain.io/api |
FIGCHAIN_CLIENT_SECRET |
A client token for the namespace |
Service accounts that authenticate with a key pair instead of a token set FIGCHAIN_PRIVATE_KEY,
FIGCHAIN_SERVICE_ACCOUNT_ID, FIGCHAIN_TENANT_ID, FIGCHAIN_NAMESPACE and, if used,
FIGCHAIN_KEY_ID.
Your S3 backup
If you have S3 backups enabled, the plugin can read schemas straight from your bucket, so builds keep working without reaching FigChain at all. Each backup carries an unencrypted section with the schemas its figs use; configuration values stay encrypted. The build needs read access to the backup object, but not your backup private key.
<configuration>
<source>s3</source>
<s3Bucket>my-figchain-backups</s3Bucket>
<s3Prefix>figchain</s3Prefix>
<s3KeyFingerprint>14e6bc45...</s3KeyFingerprint>
<s3Region>us-east-1</s3Region>
</configuration>
s3KeyFingerprint is your backup key's fingerprint, shown in the backup settings; it is part of the
backup's object key. AWS credentials come from the standard AWS provider chain (environment
variables, profile, or instance role). With the S3 source, <schemas> is optional: leave it out to
generate every schema in the backup.
The S3 source needs backups written by a current FigChain server. Older backups have no unencrypted section, and the plugin reports that rather than failing silently.
Configuration reference
| Parameter | Property | Default | Description |
|---|---|---|---|
source |
figchain.source |
api |
api or s3 |
schemas |
Schemas to generate. Required for api. |
||
stringType |
figchain.stringType |
CharSequence |
Java type for Avro strings: CharSequence, String or Utf8 |
outputDirectory |
target/generated-sources/figchain |
Where classes are written | |
skip |
figchain.skip |
false |
Skip generation |
baseUrl |
figchain.baseUrl |
$FIGCHAIN_URL |
API base URL |
clientSecret |
figchain.clientSecret |
$FIGCHAIN_CLIENT_SECRET |
Client token |
s3Bucket |
figchain.s3.bucket |
Backup bucket | |
s3Prefix |
figchain.s3.prefix |
Object prefix configured for backups | |
s3KeyFingerprint |
figchain.s3.keyFingerprint |
Backup key fingerprint | |
s3Region |
figchain.s3.region |
Bucket region | |
s3Endpoint |
figchain.s3.endpoint |
Custom endpoint for S3-compatible storage | |
s3PathStyleAccess |
figchain.s3.pathStyleAccess |
false |
Path-style URLs, often needed for MinIO |
Most projects set stringType to String so generated getters return String.
Generated class names
A schema's Avro namespace becomes the Java package and its name becomes the class name. If you
save a schema without a namespace, FigChain assigns io.figchain.<workspace>.<namespace>, so a
CheckoutSettings record in the payments namespace is generated as
io.figchain.<workspace>.payments.CheckoutSettings. Check the schema in the web app to see its
namespace.
Use the generated class with the client:
Avro class trust
Avro 1.12 only creates instances of classes it has been told to trust, so that a schema received
over the network can't make your application load arbitrary classes. The FigChain client trusts
exactly the generated classes you pass to it (such as getFig("checkout", CheckoutSettings.class))
and the record types nested inside them, so no setup is needed.
If you also read or write generated classes with Avro directly, outside the client, trust their package yourself:
Troubleshooting
Forbidden … This class is not trusted to be included in Avro schemas. The class is being
decoded by Avro outside the FigChain client; see Avro class trust.
HTTP 401 or 403 fetching a schema. The credential is missing, expired, or lacks permission to read schemas.
Schema … is not in the backup. The backup predates the schema, or no fig in the backup uses it.
Make a change in the namespace to trigger a fresh backup, or use the api source.
Generated code doesn't compile after changing a schema version. That's the plugin doing its job: your code relies on a field or type that changed. Update the code, or stay on the previous version.