Back to Scalar

Go

documentation/guides/sdks/configuration/go.md

latest3.0 KB
Original Source

Go

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

Version and general configuration

yml
go:
  version: 1.2.3
  packageName: "custom-sdk"
NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapiThe Go module package name. See Go Module Path Documentation.

Additional dependencies

yml
go:
  additionalDependencies:
    axios: "0.21.0"
NameRequiredDefault ValueDescription
additionalDependenciesfalse{}Add additional dependencies to include in the generated go.mod.

Method and parameter management

yml
go
  maxMethodParams: 4
  methodArguments: "require-security-and-request"
NameRequiredDefault ValueDescription
maxMethodParamsfalse4The maximum number of parameters a method can have before the resulting SDK endpoint is no longer "flattened" and an input object is created. 0 will use input objects always. Must match the regex pattern /^\\d+$/.
methodArgumentsfalserequire-security-and-requestDetermines how arguments for SDK methods are generated. Options: "infer-optional-args" or "require-security-and-request".

Security configuration

yml
go
  envVarPrefix: SPEAKEASY
  flattenGlobalSecurity: true
NameRequiredDefault ValueDescription
clientServerStatusCodesAsErrorsfalsetrueWhether to treat 4xx and 5xx status codes as errors.
flattenGlobalSecurityfalsenewSDKFlatten the global security configuration if there is only a single option in the spec.

Import management

yml
go
  imports:
    paths:
      callbacks: models/callbacks
      errors: models/errors
      operations: models/operations
      shared: models/components
      webhooks: models/webhooks
PathDefault ValueDescription
sharedmodels/componentsThe directory for shared components, such as reusable schemas, and data models.
operationsmodels/operationsThe directory where operation models (i.e., API endpoints) will be imported from.
errorsmodels/sdkerrorsThe directory where error models will be imported from.
callbacksmodels/callbacksThe directory where callback models will be imported from.
webhooksmodels/webhooksThe directory where webhook models will be imported from.

Error and response handling

yml
go:
  responseFormat: "envelope-http"
NameRequiredDefault ValueDescription
responseFormatfalseenvelope-httpDetermines the shape of the response envelope that is returned from SDK methods. Must be envelope-http, envelope, or flat only.