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.3author: "Your Name"packageName: "custom-sdk"
Name | Required | Default Value | Description |
---|---|---|---|
version | true | 0.0.1 | The current version of the SDK. |
packageName | true | openapi | The name of the npm package. See npm package guidelines (opens in a new tab). |
author | true | Speakeasy | The name of the author of the published package. See npm author field (opens in a new tab). |
Additional JSON Package
typescript:additionalPackageJSON:license: "MIT"
Name | Required | Default Value | Description |
---|---|---|---|
additionalPackageJSON | false | {} | 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"
Name | Required | Default Value | Description |
---|---|---|---|
dependencies | false | {} | Additional production dependencies to include in the package.json . |
devDependencies | false | {} | Additional development dependencies to include in the package.json . |
peerDependencies | false | {} | Peer dependencies for compatibility. |
Method and Paramater Management
typescript:maxMethodParams: 3methodArguments: "require-security-and-request"
Name | Required | Default Value | Description |
---|---|---|---|
maxMethodParams | false | 0 | Maximum number of parameters before an input object is created. 0 means input objects are always used. |
flatteningOrder | false | parameters-first or body-first | Determines the ordering of method arguments when flattening parameters and body fields. |
methodArguments | false | require-security-and-request | Determines how arguments for SDK methods are generated. |
Security Configuratiaon
typescript:envVarPrefix: SPEAKEASYflattenGlobalSecurity: true
Property | Description | Type | Default |
---|---|---|---|
flattenGlobalSecurity | Enables inline security credentials during SDK instantiation. Recommended: true | boolean | true |
envVarPrefix | Sets a prefix for environment variables that allows users to configure global parameters and security. | string | N/A` |
Module Management
typescript:moduleFormat: "dual"useIndexModules: true
Name | Required | Default Value | Description |
---|---|---|---|
useIndexModules | false | true | Determines if index modules (index.ts ) are generated. |
moduleFormat | false | commonjs | Specifies the module format to use when compiling the SDK (commonjs , esm , or dual ). |
Import Management
typescript:imports:option: "openapi"paths:callbacks: models/callbackserrors: models/errorsoperations: models/operationsshared: models/componentswebhooks: models/webhooks
Field | Required | Default Value | Description |
---|---|---|---|
option | false | "openapi" | Defines the type of import strategy. Typically set to "openapi" , indicating that the structure is based on the OpenAPI document. |
paths | false | {} | Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from. |
Import Paths
Component | Default Value | Description |
---|---|---|
callbacks | models/callbacks | The directory where callback models will be imported from. |
errors | models/errors | The directory where error models will be imported from. |
operations | models/operations | The directory where operation models (i.e., API endpoints) will be imported from. |
shared | models/components | The directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec. |
webhooks | models/webhooks | The directory for webhook models, if your SDK includes support for webhooks. |
Error and Response Handling
typescript:clientServerStatusCodesAsErrors: falseresponseFormat: "envelope-http"enumFormat: "union"
Property | Description | Type | Default |
---|---|---|---|
responseFormat | Defines how responses are structured. Options: envelope , envelope-http , or flat . | string | envelope-http |
enumFormat | Determines how enums are generated. Options: enum (TypeScript enums) or union (union types). | string | union |
clientServerStatusCodesAsErrors | Treats 4XX and 5XX status codes as errors. Set to false to treat them as normal responses. | boolean | true |