Typescript Configuration Options

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

Version and General Configuration

typescript:
version: 1.2.3
author: "Your Name"
packageName: "custom-sdk"
NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapiThe name of the npm package. See npm package guidelines (opens in a new tab).
authortrueSpeakeasyThe name of the author of the published package. See npm author field (opens in a new tab).

Additional JSON Package

typescript:
additionalPackageJSON:
license: "MIT"
NameRequiredDefault ValueDescription
additionalPackageJSONfalse{}Additional key/value pairs for the package.json file. Example: license, keywords, etc.

Additional Dependencies

typescript:
additionalDependencies:
dependencies:
axios: "^0.21.0"
devDependencies:
typescript: "^4.0.0"
peerDependencies:
react: "^16.0.0"
NameRequiredDefault ValueDescription
dependenciesfalse{}Additional production dependencies to include in the package.json.
devDependenciesfalse{}Additional development dependencies to include in the package.json.
peerDependenciesfalse{}Peer dependencies for compatibility.

Method and Paramater Management

typescript:
maxMethodParams: 3
methodArguments: "require-security-and-request"
NameRequiredDefault ValueDescription
maxMethodParamsfalse0Maximum number of parameters before an input object is created. 0 means input objects are always used.
flatteningOrderfalseparameters-first or body-firstDetermines the ordering of method arguments when flattening parameters and body fields.
methodArgumentsfalserequire-security-and-requestDetermines how arguments for SDK methods are generated.

Security Configuratiaon

typescript:
envVarPrefix: SPEAKEASY
flattenGlobalSecurity: true
PropertyDescriptionTypeDefault
flattenGlobalSecurityEnables inline security credentials during SDK instantiation. Recommended: truebooleantrue
envVarPrefixSets a prefix for environment variables that allows users to configure global parameters and security.stringN/A`

Module Management

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

Import Management

typescript:
imports:
option: "openapi"
paths:
callbacks: models/callbacks
errors: models/errors
operations: models/operations
shared: models/components
webhooks: models/webhooks
FieldRequiredDefault ValueDescription
optionfalse"openapi"Defines the type of import strategy. Typically set to "openapi", indicating that the structure is based on the OpenAPI document.
pathsfalse{}Customizes where different parts of the SDK (e.g., callbacks, errors, 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

typescript:
clientServerStatusCodesAsErrors: false
responseFormat: "envelope-http"
enumFormat: "union"
PropertyDescriptionTypeDefault
responseFormatDefines how responses are structured. Options: envelope, envelope-http, or flat.stringenvelope-http
enumFormatDetermines how enums are generated. Options: enum (TypeScript enums) or union (union types).stringunion
clientServerStatusCodesAsErrorsTreats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses.booleantrue