Skip to content

Commit 749a1ae

Browse files
committed
Sync open source content 🐝 (from 70736dba5645ea638e23169e22e2cd48a40c312c)
1 parent 5b54dd1 commit 749a1ae

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

docs/terraform/entity-mapping.mdx

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,22 @@ Terraform resources require an object-type root schema. When an API returns an a
315315
**Default behavior:**
316316

317317
```yaml
318-
data:
319-
type: array
320-
items:
321-
x-speakeasy-entity: Things
318+
paths:
319+
/things:
320+
get:
321+
x-speakeasy-entity-operation: Things#read
322+
responses:
323+
'200':
324+
description: OK
325+
content:
326+
application/json:
327+
schema:
328+
type: array
329+
items:
330+
x-speakeasy-entity: Things
322331
```
323332

324-
In this example, `data` appears twice but means different things:
325-
- `data:` is your OpenAPI property name
326-
- The wrapping attribute is also named `data` by default (unrelated to the property name)
333+
Since the response is `type: array`, Speakeasy wraps it in a `data` attribute for Terraform compatibility.
327334

328335
Access in Terraform:
329336

@@ -334,11 +341,20 @@ data.my_things_list.data[0].id
334341
**Customize the wrapper name:**
335342

336343
```yaml
337-
data:
338-
x-speakeasy-wrapped-attribute: items
339-
type: array
340-
items:
341-
x-speakeasy-entity: Things
344+
paths:
345+
/things:
346+
get:
347+
x-speakeasy-entity-operation: Things#read
348+
responses:
349+
'200':
350+
description: OK
351+
content:
352+
application/json:
353+
schema:
354+
x-speakeasy-wrapped-attribute: items
355+
type: array
356+
items:
357+
x-speakeasy-entity: Things
342358
```
343359

344360
Now the wrapping attribute is named `items` instead:
@@ -348,7 +364,7 @@ data.my_things_list.items[0].id
348364
```
349365

350366
<Callout title="Note" type="info">
351-
The wrapping attribute name is a Terraform construct created by Speakeasy, completely separate from your OpenAPI property names. Use `x-speakeasy-wrapped-attribute` to customize it.
367+
The wrapping attribute name is a Terraform construct created by Speakeasy, completely separate from your API's response structure. Use `x-speakeasy-wrapped-attribute` to customize it.
352368
</Callout>
353369

354370
### Resources with Soft Delete

0 commit comments

Comments
 (0)