Back to Scalar

Java

documentation/guides/sdks/configuration/java.md

latest5.2 KB
Original Source

Java

This section details the available configuration options for the Java SDK. All configuration is managed in the gen.yaml file under the java section.

Version and general configuration

yml
java:
  version: 1.2.3
  projectName: "openapi"
NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
projectNametrueopenapiAssigns Gradle rootProject.name, which names the Gradle build. See Gradle Naming.

Publishing

yml
java:
  groupID: "com.mycompany"
  artifactID: "my-sdk"
  githubURL: "https://github.com/mycompany/my-sdk"
  companyName: "My Company"
  companyURL: "https://www.mycompany.com"
  companyEmail: "[email protected]"
NameRequiredDefault ValueDescription
groupIDtrueorg.openapisThe group ID used for namespacing the package. Typically the reversed domain of an organization.
artifactIDtrueopenapiThe artifact ID used for namespacing the package, usually the name of the project.
githubURLfor publishinggithub.com/owner/repoThe GitHub URL where the artifact is hosted. Sets metadata required by Maven.
companyNamefor publishingMy CompanyThe name of your company. Sets metadata required by Maven.
companyURLfor publishingwww.mycompany.comYour company's homepage URL. Sets metadata required by Maven.
companyEmailfor publishing[email protected]A support email address for your company. Sets metadata required by Maven.

Base package name

This package will be where the primary SDK class is located (and sub-packages will hold various types of associated generated classes):

yaml
java:
  packageName: com.mycompany.sdk

Additional Dependencies

yml
java:
  additionalDependencies:
    - "implementation:com.fasterxml.jackson.core:jackson-databind:2.12.3"
    - "testImplementation:junit:junit:4.13.2"
NameRequiredDefault ValueDescription
additionalDependenciesfalse[]Adds additional dependencies to include in build.gradle. Format: scope:groupId:artifactId:version.
additionalPluginsfalse[]Adds additional plugins to include in build.gradle. Format: id("plugin.id") version "x.x.x".

License

yml
java:
  license:
    name: "The MIT License (MIT)"
    url: "https://mit-license.org/"
    shortName: "MIT"
NameRequiredDefault ValueDescription
licensefalseMIT LicenseLicense information. Defaults to the MIT license if not provided.

Method and parameter management

yml
java:
  maxMethodParams: 4
NameRequiredDefault ValueDescription
maxMethodParamsfalse4Maximum number of parameters before an input object is created. 0 means input objects are always used.

Security configuration

yml
java:
  flattenGlobalSecurity: true
PropertyDescriptionTypeDefault
flattenGlobalSecurityEnables inline security credentials during SDK instantiation. Recommended: truebooleantrue

Module management

yml
java:
  moduleFormat: "dual"
  useIndexModules: true
NameRequiredDefault ValueDescription
useIndexModulesfalsetrueDetermines if index modules are generated.
moduleFormatfalsecommonjsSets the module format to use when compiling the SDK (commonjs, esm, or dual).

Import management

yml
java:
  imports:
    paths:
      callbacks: models/callbacks
      errors: models/errors
      operations: models/operations
      shared: models/components
      webhooks: models/webhooks
FieldRequiredDefault ValueDescription
pathsfalse{}Customizes where different parts of the SDK (e.g., callbacks, errors, and operations) will be imported from.

Import paths

ComponentDefault ValueDescription
callbacksmodels/callbacksThe directory where callback models will be imported from.
errorsmodels/errorsThe directory where error models will be imported from.
operationsmodels/operationsThe directory where operation models (i.e., API endpoints) will be imported from.
sharedmodels/componentsThe directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec.
webhooksmodels/webhooksThe directory for webhook models, if your SDK includes support for webhooks.

Error and response handling

yml
java:
  clientServerStatusCodesAsErrors: false
NameRequiredDefault ValueDescription
clientServerStatusCodesAsErrorsfalsetrueWhether to treat 4xx and 5xx status codes as errors. Options: true or false.