Timeouts

With Speakeasy, you can add request timeouts to specific operations in your SDK. You can enable timeouts globally for all operations or on a per-operation basis by using the x-speakeasy-timeout extension in your OpenAPI document. The SDK end user can override the default configuration by passing in a timeout option at runtime. Timeout values are always provided in milliseconds.

Global Timeouts


openapi: 3.0.3
info:
title: Swagger Petstore - OpenAPI 3.0
version: 1.0.11
servers:
- url: https://petstore3.swagger.io/api/v3
x-speakeasy-timeout: 1000

If you add the x-speakeasy-timeout extension to the root of the OpenAPI document, the SDK Generator will generate a global timeout configuration that will be used for all requests made by the SDK.

Per-request Timeouts

Add the x-speakeasy-timeout extension to any operation to override the global timeout configuration for that operation, or to configure timeouts for the operation if timeouts aren't defined globally.


openapi: 3.0.3
info:
title: Swagger Petstore - OpenAPI 3.0
version: 1.0.11
servers:
- url: https://petstore3.swagger.io/api/v3
paths:
/pet/findByStatus:
get:
operationId: findPetsByStatus
x-speakeasy-timeout: 2000
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: false
explode: true
schema:
type: string
default: available
enum:
- available
- pending
- sold
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value

SDK Usage Override

Users of the SDK can override the timeout configuration globally or at the request level.

Global

To override the timeout configuration globally, initialize the SDK object with the appropriate options parameter. In all cases, if no override is provided, the timeout configuration provided in the OpenAPI document will be used.


const sdk = new SDK({timeoutMs: 100});

Request-Level Override

Users can override the timeout config on a per operation level.


const sdk = new SDK({});
await sdk.findPetsByStatus(request, {
timeoutMs: 1000,
});