Skip to content

Additional properties

When OpenAPI schemas use the additionalProperties keyword, Speakeasy generates SDKs that handle these flexible object types automatically.

Important: additionalProperties is an internal implementation detail. Pass objects with all properties directly - the SDK handles serialization and validation automatically.

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.

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: true
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" }
});

Constrain additional properties to a specific type:

components:
schemas:
StringOnlyObject:
type: object
properties:
title:
type: string
description:
type: string
additionalProperties:
type: string