Skip to content

Commit 317fb2c

Browse files
committed
validate apirequest query params via validate
1 parent c4b9073 commit 317fb2c

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/components/APIRequest.astro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const props = z
1717
parameters: z.record(z.string(), z.any()).optional(),
1818
json: z.union([Record, z.array(Record)]).optional(),
1919
form: Record.optional(),
20-
query: z.record(z.string(), z.string()).optional(),
2120
})
2221
.strict();
2322
@@ -163,7 +162,6 @@ const tokenGroups = operation["x-api-token-group"];
163162
headers={headers}
164163
json={json}
165164
form={form}
166-
query={query}
167165
code={{
168166
title: operation.summary,
169167
}}

src/content/docs/style-guide/components/api-request.mdx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ import { APIRequest } from "~/components";
5454
},
5555
]}
5656
/>
57+
58+
<APIRequest
59+
path="/zones/{zone_id}/page_shield/scripts"
60+
method="GET"
61+
parameters={{
62+
direction: "asc"
63+
}}
64+
/>
5765
```
5866

5967
## `<APIRequest>` Props
@@ -80,7 +88,16 @@ The HTTP method to use.
8088

8189
**type:** `Record<string, any>`
8290

83-
The path parameters to substitute.
91+
The parameters to substitute - either in the URL path or as query parameters.
92+
93+
For example, `/zones/{zone_id}/page_shield/scripts` can be transformed into `/zones/123/page_shield/scripts?direction=asc` with the following:
94+
95+
```mdx
96+
parameters={{
97+
zone_id: "123",
98+
direction: "asc"
99+
}}
100+
```
84101

85102
If not provided, the component will default to an environment variable. For example, `{setting_id}` will be replaced with `$SETTING_ID`.
86103

@@ -98,10 +115,4 @@ If required properties are missing, the component will throw an error.
98115

99116
The FormData payload to send.
100117

101-
This field is not currently validated against the schema.
102-
103-
### `query`
104-
105-
**type:** `Record<string, string>`
106-
107-
URL query parameters to append to the request URL.
118+
This field is not currently validated against the schema.

0 commit comments

Comments
 (0)