Skip to content

Commit

Permalink
Multiple improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Jun 16, 2023
1 parent 3a4f410 commit b7648f6
Show file tree
Hide file tree
Showing 9 changed files with 532 additions and 402 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-ligers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": patch
---

Clone response internally
5 changes: 5 additions & 0 deletions .changeset/khaki-bobcats-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": minor
---

Expose createFinalURL() logic for testing
5 changes: 5 additions & 0 deletions .changeset/khaki-cycles-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": minor
---

Automatically remove `undefined` and `null` query params without requiring querySerializer
5 changes: 5 additions & 0 deletions .changeset/long-llamas-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": patch
---

Strip trailing slashes from baseUrl
5 changes: 5 additions & 0 deletions .changeset/mighty-dots-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": patch
---

Fix querySerializer typing
5 changes: 5 additions & 0 deletions .changeset/rude-bikes-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": minor
---

Allow overriding of JSON body parsing
17 changes: 9 additions & 8 deletions docs/src/content/docs/openapi-fetch/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ const { get, put, post, del, options, head, patch, trace } = createClient<paths>
const { data, error, response } = await get("/my-url", options);
```

| Name | Type | Description |
| :---------------- | :-----------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params` | ParamsObject | Provide `path` and `query` params from the OpenAPI schema |
| `params.path` | `{ [name]: value }` | Provide all `path` params (params that are part of the URL) |
| `params.query` | `{ [name]: value }` | Provide all `query params (params that are part of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams" target="_blank" rel="noopener noreferrer">searchParams</a> |
| `body` | `{ [name]:value }` | The <a href="https://spec.openapis.org/oas/latest.html#request-body-object" target="_blank" rel="noopener noreferrer">requestBody</a> data, if needed (PUT/POST/PATCH/DEL only) |
| `querySerializer` | QuerySerializer | (optional) Override default param serialization (see [Parameter Serialization](#parameter-serialization)) |
| (Fetch options) | | Any valid fetch option (`headers`, `mode`, `cache`, `signal` …) (<a href="https://developer.mozilla.org/en-US/docs/Web/API/fetch#options" target="_blank" rel="noopener noreferrer">docs</a>) |
| Name | Type | Description |
| :---------------- | :-------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params` | ParamsObject | Provide `path` and `query` params from the OpenAPI schema |
| `params.path` | `{ [name]: value }` | Provide all `path` params (params that are part of the URL) |
| `params.query` | `{ [name]: value }` | Provide all `query params (params that are part of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams" target="_blank" rel="noopener noreferrer">searchParams</a> |
| `body` | `{ [name]:value }` | The <a href="https://spec.openapis.org/oas/latest.html#request-body-object" target="_blank" rel="noopener noreferrer">requestBody</a> data, if needed (PUT/POST/PATCH/DEL only) |
| `querySerializer` | QuerySerializer | (optional) Override default param serialization (see [Parameter Serialization](#parameter-serialization)) |
| `parseAs` | `"json" \| "arrayBuffer" \| "blob" \| "text"` | Decide how to parse the response body (default: `"json"`) |
| (Fetch options) | | Any valid fetch option (`headers`, `mode`, `cache`, `signal` …) (<a href="https://developer.mozilla.org/en-US/docs/Web/API/fetch#options" target="_blank" rel="noopener noreferrer">docs</a>) |

### Parameter Serialization

Expand Down
Loading

0 comments on commit b7648f6

Please sign in to comment.