Java Configuration
You can customize the behavior of the Java SDK generator in generators.yml
:
SDK Configuration Options
base-api-exception-class-name
Customizes the name of the base API exception class that all API-specific exceptions will extend. This allows you to define a custom base exception class name for better integration with your existing error handling patterns.
base-exception-class-name
Specifies the name of the base exception class that all generated exceptions will inherit from. This provides a common parent class for all SDK exceptions, enabling consistent exception handling patterns.
client-class-name
The provided string will be used as the client class name.
custom-dependencies
Example:
disable-required-property-builder-checks
When enabled, disables validation checks in builder patterns for required properties. This removes compile-time checks that ensure all required fields are set before building an object, providing more flexibility but less safety.
enable-extensible-builders
When enabled, generates extensible builder classes that support customization through inheritance. This allows you to add custom code to extend the generated builders with additional functionality.
enable-forward-compatible-enums
When enabled, generates enum classes that can handle unknown values gracefully. This allows the SDK to process new enum values that may be added to the API without breaking existing client code, improving forward compatibility.
enable-inline-types
When enabled, generates inline types for nested schemas instead of creating separate classes. This results in cleaner type definitions where nested objects are defined within their parent types, reducing the number of generated files.
enable-public-constructors
When enabled, generates public constructors for model types.
generate-unknown-as-json-node
When enabled, generates unknown or untyped properties as structured JSON objects instead of raw Object types. This provides better type safety and easier manipulation of dynamic JSON content while maintaining flexibility for unknown data structures.
inline-file-properties
Controls whether file upload properties are generated as inline request properties instead of separate method parameters. When enabled, file fields become part of the request object rather than being passed as individual function arguments.
inline-path-parameters
When enabled, path parameters are included as properties in the request object instead of being passed as separate method parameters. This creates a more unified request structure where all parameters are grouped together.
json-include
Controls Jackson’s JSON serialization behavior for optional fields. Use ‘non-empty’ to exclude null and empty values, or ‘non-absent’ to only exclude null values while preserving empty collections and strings.
package-layout
Determines the organization of generated Java packages. Choose ‘nested’ for a hierarchical package structure that mirrors your API organization, or ‘flat’ for a simpler structure with fewer nested packages.
package-prefix
By default, the generated SDK will use the package prefix com.{orgName}.api
, where {orgName}
is your Fern organization name (defined in fern.config.json
).
To override this, you can specify the package-prefix
field in your generators.yml
configuration.
publish-to
Publish target for Maven packages. Use central
for Maven Central Portal or ossrh
for legacy Nexus Repository.
wrapped-aliases
When enabled, generates wrapper types for each alias to increase type-safety.
For example, if you have an alias ResourceId: string
then if this is true, the
generator will generate a ResourceId.java
file. If false, it will just treat it
as java.util.String
.
Publishing metadata configuration options
If you want to customize how your publishing metadata looks in your
build.gradle
file, update the metadata
field in generators.yml
.
author
Specifies the author name that will appear in the generated package metadata and build configuration files.
Sets the contact email address for the package author that will be included in the generated package metadata.
license
Defines the software license for the generated SDK. Choose from standard licenses like ‘MIT’ or ‘Apache-2.0’, or specify a custom license name.
package-description
Provides a description of the SDK package that will appear in package metadata and documentation. This helps users understand what the SDK is for and its purpose.
reference-url
Sets the reference URL (typically the API documentation or project website) that will be included in the package metadata for users to find additional information.