-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to select the response content type (#1597)
- Loading branch information
1 parent
92f4b96
commit 1f7ad9d
Showing
4 changed files
with
79 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"openapi-fetch": patch | ||
--- | ||
|
||
Allow to select the response content type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1049,6 +1049,42 @@ describe("client", () => { | |
|
||
expect(data.byteLength).toBe(2); | ||
}); | ||
|
||
it("use the selected content", async () => { | ||
const client = createClient<paths, "application/ld+json">(); | ||
mockFetchOnce({ | ||
status: 200, | ||
headers: { "Content-Type": "application/ld+json" }, | ||
body: JSON.stringify({ | ||
"@id": "some-resource-identifier", | ||
email: "[email protected]", | ||
name: null, | ||
}), | ||
}); | ||
const { data } = await client.GET("/multiple-response-content", { | ||
headers: { | ||
Accept: "application/ld+json", | ||
}, | ||
}); | ||
|
||
data satisfies | ||
| { | ||
"@id": string; | ||
email: string; | ||
name?: string; | ||
} | ||
| undefined; | ||
|
||
if (!data) { | ||
throw new Error(`Missing response`); | ||
} | ||
|
||
expect(data).toEqual({ | ||
"@id": "some-resource-identifier", | ||
email: "[email protected]", | ||
name: null, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
|