Skip to main content

Define Global Parameters

Using the x-speakeasy-globals extension it is possible to define parameters that can be configured globally on the main SDK instance and then get populated automatically for any operations that use them. This is useful for things like customer IDs or other global configuration that is required for all operations.

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 global parameter's name, in and schema match a parameter in an operation then 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 and are only supported for "primitive" schemas of type string, number, integer, and boolean.

This will generate output like the following:

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()