Timeouts
With Speakeasy, you can configure request timeouts in an SDK using the x-speakeasy-timeout
extension in your OpenAPI document. Timeouts can be enabled globally for all operations or on a per-operation basis. 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.3info:title: Swagger Petstore - OpenAPI 3.0version: 1.0.11servers:- url: https://petstore3.swagger.io/api/v3x-speakeasy-timeout: 1000
Adding the x-speakeasy-timeout
extension to the root of the OpenAPI document configures a global timeout for all requests made by the SDK.
Per-request timeouts
Adding the x-speakeasy-timeout
extension to any operation overrides the global timeout configuration for that operation or sets a timeout if no global configuration exists.
openapi: 3.0.3info:title: Swagger Petstore - OpenAPI 3.0version: 1.0.11servers:- url: https://petstore3.swagger.io/api/v3paths:/pet/findByStatus:get:operationId: findPetsByStatusx-speakeasy-timeout: 2000parameters:- name: statusin: querydescription: Status values that need to be considered for filterrequired: falseexplode: trueschema:type: stringdefault: availableenum:- available- pending- soldresponses:"200":description: successful operationcontent:application/json:schema:type: arrayitems:$ref: "#/components/schemas/Pet"application/xml:schema:type: arrayitems:$ref: "#/components/schemas/Pet""400":description: Invalid status value
Overriding timeout configuration
Users of the SDK can override the timeout configuration globally or at the request level.
Globally overriding timeout configuration
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});
Overriding timeout configuration at the request level
Users can override the timeout config on a per-operation basis.
const sdk = new SDK({});await sdk.findPetsByStatus(request, {timeoutMs: 1000,});