Configure SDK generation in Postman

View as Markdown

The Postman SDK Generator postman-sdk.config.json config file contains the configuration used by the Postman SDK CLI to generate SDKs. Power users who require deeper customization can provide a full postman-sdk.config.json file. See Advanced options for more information.

At a minimum, set the location of your API specification and the SDK languages you want to generate in the config file:

1{
2 ...
3 "specFilePath": "https://petstore3.swagger.io/api/v3/openapi.json",
4 "languages": ["typescript"]
5 ...
6}

The config file contains options that enable you to customize the SDKs you generate. One of the most powerful features of the Postman SDK Generator is the ability to get fine-grained control over the SDK generation process.

The Postman SDK CLI uses a configuration file instead of extensions in your API specification to allow you to keep a separation between your specification and SDK generation. This provides one source for the configuration, and allows you to quickly make changes without having to redeploy your API if your specification is created by your API gateway.

Create and manage the Postman SDK config file

To create the config file, run the postman sdk init command.

By default, the config file is located in the .postman/config.json root of your project. When you run CLI commands such as postman sdk generate, the CLI looks for this config file in the current working directory.

You can change the name and location of the config file by passing the --config option to the CLI commands. This supports local and remote config files.

$postman sdk generate --config <PATH_OF_POSTMAN_CONFIG_FILE>

The specFilePath option in the config file is always relative to the current working directory that the CLI is being run from, not relative to the config file location.

Postman SDK config file structure

The config file defines the SDK to create, along with the configuration based on your API. It also defines sections for generic customizations, language specific customizations, publishing, and configuring validation.

1{
2 "schemaVersion": "1",
3 "workspace": {},
4 "entities": {},
5 "sdk": {
6 "sdkName": "",
7 "languages": [
8 "typescript"
9 ],
10 "customizations": {
11 "environments": [],
12 "license": {
13 "type": "NONE"
14 },
15 "retry": {
16 "enabled": true,
17 "maxAttempts": 3,
18 "retryDelay": 150
19 }
20 },
21 "languageOptions": {
22 "typescript": {
23 "bundle": true,
24 "denoteCommon": false,
25 "exportClassDefault": false
26 },
27 "java": {},
28 "python": {},
29 "analytics": {
30 "enabled": true,
31 "exporter": "otlp-http",
32 "endpoint": "https://insights.postman.com/v3/traces",
33 "headers": {
34 "Content-Type": "application/json"
35 // any other custom header
36 },
37 "batchSize": 100,
38 "scheduledDelayMillis": 5000,
39 "serviceName": "your-sdk"
40 }
41 }
42 }
43}

Advanced options

The following topics provide more information about config file sections: