Skip to content

Commit 82a84f6

Browse files
committed
Sync open source content 🐝 (from cde2f02cd995796df17eee133998cb35a652419f)
1 parent af3bc95 commit 82a84f6

4 files changed

Lines changed: 45 additions & 5 deletions

File tree

docs/sdks/customize/data-model/enums.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class EnumField(str, Enum):
140140
## Open vs closed enums
141141

142142
<Callout title="Note" type="info">
143-
This feature is currently supported in Go, Python, TypeScript, Java, C#, and
144-
Ruby SDKs.
143+
This feature is currently supported in Go, Python, TypeScript, Java, C#,
144+
Ruby, and Terraform.
145145
</Callout>
146146

147147
By default, enums defined in OpenAPI are considered closed during code

docs/sdks/manage/forward-compatibility.mdx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ Generator options enable additional forward compatibility features. These are co
255255
laxCoercion: "Contact us",
256256
smartUnions: "",
257257
},
258+
{
259+
language: "Terraform",
260+
enums: "",
261+
unions: "Contact us",
262+
requiredFields: "Contact us",
263+
laxCoercion: "Contact us",
264+
smartUnions: "Contact us",
265+
},
258266
{
259267
language: "PHP",
260268
enums: "Contact us",
@@ -317,12 +325,18 @@ Generator options enable additional forward compatibility features. These are co
317325
forwardCompatibleEnumsByDefault: true
318326
unionStrategy: populated-fields`,
319327
},
328+
{
329+
label: "Terraform",
330+
language: "yaml",
331+
code: `terraform:
332+
forwardCompatibleEnumsByDefault: true`,
333+
},
320334
]}
321335
/>
322336

323337
### Forward-compatible enums
324338

325-
When `forwardCompatibleEnumsByDefault` is enabled (the default), enums accept unknown values instead of rejecting the response:
339+
When `forwardCompatibleEnumsByDefault` is enabled (the default, except for Terraform), enums accept unknown values instead of rejecting the response:
326340

327341
```typescript
328342
const notification = await sdk.notifications.get(id);
@@ -372,7 +386,7 @@ When `unionStrategy` is set to `populated-fields` (the default for new TypeScrip
372386
This prevents issues where one union variant is a subset of another and the wrong variant gets selected due to ordering.
373387

374388
<Callout type="info" title="Per-schema overrides">
375-
Individual enums and unions can override global defaults using `x-speakeasy-unknown-values: allow` or `x-speakeasy-unknown-values: disallow` in the OpenAPI spec. See the [TypeScript configuration reference](/docs/speakeasy-reference/generation/ts-config#forward-compatibility) or [Ruby configuration reference](/docs/speakeasy-reference/generation/ruby-config#forward-compatibility) for all available options.
389+
Individual enums and unions can override global defaults using `x-speakeasy-unknown-values: allow` or `x-speakeasy-unknown-values: disallow` in the OpenAPI spec. See the [TypeScript configuration reference](/docs/speakeasy-reference/generation/ts-config#forward-compatibility), [Ruby configuration reference](/docs/speakeasy-reference/generation/ruby-config#forward-compatibility), or [Terraform configuration reference](/docs/speakeasy-reference/generation/terraform-config#forward-compatibility) for all available options.
376390
</Callout>
377391

378392
## Evolving APIs safely

docs/speakeasy-reference/extensions.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ x-speakeasy-extension-rewrite:
8282
{ extension: "x-speakeasy-wrapped-attribute", description: "Enables additional API operation data to be placed under a specifically named attribute." },
8383
{ extension: "x-speakeasy-xor-with", description: "Indicate mutually exclusive properties to prevent incompatible combinations in Terraform configurations." },
8484
{ extension: "x-speakeasy-match", description: "Adjusts an API parameter name to align with a Terraform state property." },
85-
{ extension: "x-speakeasy-response-filter", description: "Enable client-side filtering of list API responses in data resources by marking response properties that Terraform users can filter on." }
85+
{ extension: "x-speakeasy-response-filter", description: "Enable client-side filtering of list API responses in data resources by marking response properties that Terraform users can filter on." },
86+
{ extension: "x-speakeasy-unknown-values", description: "Control whether an enum is open or closed in the generated Terraform provider. Set to `allow` to accept unknown enum values or `disallow` to reject them. Can also be enabled globally via the `forwardCompatibleEnumsByDefault` config option." }
8687
]}
8788
columns={[
8889
{ key: "extension", header: "Terraform extension" },

docs/speakeasy-reference/generation/terraform-config.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@ terraform:
9191
]}
9292
/>
9393

94+
## Forward compatibility
95+
96+
```yml
97+
terraform:
98+
forwardCompatibleEnumsByDefault: true
99+
```
100+
101+
<Table
102+
data={[
103+
{
104+
name: "forwardCompatibleEnumsByDefault",
105+
required: "false",
106+
default: "false",
107+
description:
108+
"When true, enums used in responses are generated as open enums that accept unknown values. This prevents new enum values added by the API from breaking the Terraform provider. Individual enums can be controlled with `x-speakeasy-unknown-values: allow` or `x-speakeasy-unknown-values: disallow` in the OpenAPI spec.",
109+
},
110+
]}
111+
columns={[
112+
{ key: "name", header: "Name" },
113+
{ key: "required", header: "Required" },
114+
{ key: "default", header: "Default Value" },
115+
{ key: "description", header: "Description" },
116+
]}
117+
/>
118+
94119
## Environment variables
95120

96121
```yml

0 commit comments

Comments
 (0)