Define Global Parameters

You can use the x-speakeasy-globals extension to define parameters that can be configured globally on the main SDK instance and populated automatically for any operations that use them. This is useful for global configuration that is required for all operations, for example, customer IDs.

openapi: 3.1.0
info:
  title: Test
  version: 0.0.1
servers:
  - url: https://httpbin.org
x-speakeasy-globals:
  parameters:
    - name: customerId
      in: path
      schema:
        type: string
paths:
  /api/{customerId}:
    get:
      operationId: getTest
      parameters:
        - name: customerId # If this matches a global parameter it will be populated automatically
          in: path
          schema:
            type: string
      responses:
        "200":
          description: OK

If the name, in, and schema values of a global parameter match a parameter in an operation, the global parameter will be populated automatically. If the global parameter is not used in the operation, then it will be ignored.

Globals will work with in: query or in: path. Only the primitive types string, number, integer, and boolean can be used to define global parameters.

The global parameter definitions in our sample above will generate the following output:

import example
from example.models import shared
 
s = example.SDK(
    security=shared.Security(
        api_key="YOUR_API_KEY_HERE",
    ),
    customer_id=548814, # customerId can be set when instantiating the SDK and is used for all compatible operations
)
 
res = s.getTest()