SDKs
Additional properties
When OpenAPI schemas use the additionalProperties keyword, Speakeasy generates SDKs that handle these flexible object types automatically.
Using additionalProperties in SDKs
Section titled “Using additionalProperties in SDKs”Important: additionalProperties is an internal implementation detail. Pass objects with all properties directly - the SDK handles serialization and validation automatically.
The Speakeasy approach
Section titled “The Speakeasy approach”Speakeasy sets additionalProperties to false by default unless explicitly defined otherwise. This encourages fully-typed objects with clear documentation. Most developers prefer closed objects by default, but setting additionalProperties: false in every schema would be tedious. Most backend frameworks that generate OpenAPI schemas don’t add additionalProperties: false, even when that’s the intended behavior.
Using additionalProperties: true
Section titled “Using additionalProperties: true”Set additionalProperties: true to accept arbitrary fields beyond the defined properties. This is useful for accepting unpredictable fields or allowing future extensions without schema updates.
components: schemas: FlexibleObject: type: object properties: title: type: string description: type: string additionalProperties: trueGenerated type structure
Section titled “Generated type structure”export type FlexibleObject = { title: string; description: string; additionalProperties: Record<string, any>; // Internal field - do not interact directly}await sdk.items.create({ title: "My Item", description: "A flexible item", customField: "custom value", anotherField: 123, metadata: { key: "value" }});Using typed additionalProperties
Section titled “Using typed additionalProperties”Constrain additional properties to a specific type:
components: schemas: StringOnlyObject: type: object properties: title: type: string description: type: string additionalProperties: type: string