Python Configuration Options
This section details the available configuration options for the Python SDK. All configuration is managed in the gen.yaml
file under the python
section.
Version and General Configuration
python:version: 1.2.3authors: ["Your Name"]packageName: "openapi"
Name | Required | Default Value | Description |
---|---|---|---|
version | true | 0.0.1 | The current version of the SDK. |
packageName | true | openapi | The distribution name of the PyPI package. See Python Package Metadata (opens in a new tab). |
authors | true | ["Speakeasy"] | Authors of the published package. See Poetry Authors Field (opens in a new tab). |
Description and URLs
python:description: "Python Client SDK Generated by Speakeasy."homepage: "https://example.com"documentationUrl: "https://example.com/docs"
Name | Required | Default Value | Description |
---|---|---|---|
description | false | "Python Client SDK Generated by Speakeasy." | A short description of the project. See Poetry Description Field (opens in a new tab). |
homepage | false | null | The URL for the homepage of the project. |
documentationUrl | false | null | The URL for the project documentation. |
Additional Dependencies
python:additionalDependencies:main:requests: "^2.25.1"dev:pytest: "^6.2.1"
Name | Required | Default Value | Description |
---|---|---|---|
additionalDependencies | false | {} | Specify additional dependencies to include in the generated pyproject.toml file. |
Method and Paramater Management
python:maxMethodParams: 4flatteningOrder: "parameters-first"methodArguments: "infer-optional-args"
Name | Required | Default Value | Description |
---|---|---|---|
flattenRequests | false | true | Turn request parameters and body fields into a flat list of method arguments. This takes precedence over maxMethodParams. If there is no request body then maxMethodParams will be respected. |
maxMethodParams | false | 9999 | Maximum number of parameters before an input object is created. 0 means input objects are always used. |
flatteningOrder | false | parameters-first | Determines the ordering of method arguments when flattening parameters and body fields. parameters-first or body-first |
methodArguments | false | require-security-and-request | Determines how arguments for SDK methods are generated. |
Security Configuratiaon
python:envVarPrefix: "SPEAKEASY"flattenGlobalSecurity: true
Name | Required | Default Value | Description |
---|---|---|---|
flattenGlobalSecurity | false | true | Enables inline security credentials during SDK instantiation. |
envVarPrefix | false | "" | Sets a prefix for environment variables that allows users to configure global parameters and security. |
Import Management
python:imports:option: "openapi"paths:callbacks: "models/callbacks"errors: "models/errors"operations: "models/operations"shared: "models/shared"webhooks: "models/webhooks"
Field | Required | Default Value | Description |
---|---|---|---|
option | false | "openapi" | Defines the type of import strategy. Typically set to "openapi" , indicating that the structure is based on the OpenAPI document. |
paths | false | {} | Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from. |
Import Paths
Component | Default Value | Description |
---|---|---|
callbacks | models/callbacks | The directory where callback models will be imported from. |
errors | models/errors | The directory where error models will be imported from. |
operations | models/operations | The directory where operation models (i.e., API endpoints) will be imported from. |
shared | models/components | The directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec. |
webhooks | models/webhooks | The directory for webhook models, if your SDK includes support for webhooks. |
Error and Response Handling
python:clientServerStatusCodesAsErrors: trueresponseFormat: "flat"enumFormat: "enum"
Name | Required | Default Value | Description |
---|---|---|---|
clientServerStatusCodesAsErrors | false | true | Whether to treat 4XX and 5XX status codes as errors. |
responseFormat | false | flat | Defines how responses are structured. Options: envelope , envelope-http , or flat . |
enumFormat | false | enum | Determines how enums are generated. Options: enum (Python enums) or union (union types). |