Skip to content

Commit

Permalink
Update swr-openapi dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
htunnicliff committed Nov 7, 2024
1 parent 626f490 commit d95c474
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-snails-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"swr-openapi": minor
---

Update dependencies
10 changes: 5 additions & 5 deletions packages/swr-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"version": "pnpm run build"
},
"peerDependencies": {
"openapi-fetch": "0.12",
"openapi-typescript": "7",
"openapi-fetch": "workspace:*",
"openapi-typescript": "workspace:7.x",
"react": "18 || 19",
"swr": "2",
"typescript": "^5.x"
Expand All @@ -68,7 +68,7 @@
}
},
"dependencies": {
"openapi-typescript-helpers": "0.0.13",
"openapi-typescript-helpers": "workspace:*",
"type-fest": "4.26.1"
},
"devDependencies": {
Expand All @@ -79,8 +79,8 @@
"husky": "9.1.5",
"lint-staged": "15.2.10",
"lodash": "4.17.21",
"openapi-fetch": "0.12.0",
"openapi-typescript": "7.4.0",
"openapi-fetch": "workspace:*",
"openapi-typescript": "workspace:7.x",
"react": "18.3.1",
"swr": "2.2.5",
"typescript": "5.5.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/swr-openapi/src/__test__/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Pet = components["schemas"]["Pet"];
type PetInvalid = ErrorResponseJSON<paths["/pet/{petId}"]["get"]>;
type PetStatusInvalid = ErrorResponseJSON<paths["/pet/findByStatus"]["get"]>;
expectTypeOf<Pet>().toMatchTypeOf<{ name: string }>();
expectTypeOf<PetInvalid>().toMatchTypeOf<{ message: string }>();
expectTypeOf<PetInvalid>().toMatchTypeOf<{ message: string } | undefined>();
expectTypeOf<PetStatusInvalid>().toMatchTypeOf<{ message: string }>();

// Set up hooks
Expand Down Expand Up @@ -383,7 +383,7 @@ describe("TypesForRequest", () => {
it("returns correct error", () => {
expectTypeOf<GetPet["Error"]>().toEqualTypeOf<PetInvalid>();
expectTypeOf<FindPetsByStatus["Error"]>().toEqualTypeOf<PetStatusInvalid>();
expectTypeOf<FindPetsByTags["Error"]>().toEqualTypeOf<never>();
expectTypeOf<FindPetsByTags["Error"]>().toEqualTypeOf<undefined>();
});

it("returns correct path params", () => {
Expand Down Expand Up @@ -430,7 +430,7 @@ describe("TypesForRequest", () => {
it("returns correct SWR config", () => {
expectTypeOf<GetPet["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet, PetInvalid>>();
expectTypeOf<FindPetsByStatus["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], PetStatusInvalid>>();
expectTypeOf<FindPetsByTags["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], never>>();
expectTypeOf<FindPetsByTags["SWRConfig"]>().toEqualTypeOf<SWR.SWRConfiguration<Pet[], undefined>>();
});

it("returns correct SWR response", () => {
Expand All @@ -441,7 +441,7 @@ describe("TypesForRequest", () => {
SWR.SWRResponse<Pet[], PetStatusInvalid, SWR.SWRConfiguration<Pet[], PetStatusInvalid>>
>();
expectTypeOf<FindPetsByTags["SWRResponse"]>().toEqualTypeOf<
SWR.SWRResponse<Pet[], never, SWR.SWRConfiguration<Pet[], never>>
SWR.SWRResponse<Pet[], undefined, SWR.SWRConfiguration<Pet[], undefined>>
>();
});
});
4 changes: 2 additions & 2 deletions packages/swr-openapi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type TryKey<T, K extends PropertyKey> = T extends { [Key in K]?: unknown } ? T[K
* Provides specific types used within a given request
*/
export type TypesForRequest<
Paths extends {},
Paths extends Record<string | number, any>,
Method extends Extract<HttpMethod, keyof Paths[keyof Paths]>,
Path extends PathsWithMethod<Paths, Method>,
// ---
Expand Down Expand Up @@ -42,6 +42,6 @@ export type TypesForRequest<
* Uses {@link TypesForRequest}
*/
export type TypesForGetRequest<
Paths extends {},
Paths extends Record<string | number, any>,
Path extends PathsWithMethod<Paths, Extract<"get", keyof Paths[keyof Paths]>>,
> = TypesForRequest<Paths, Extract<"get", keyof Paths[keyof Paths]>, Path>;
42 changes: 6 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d95c474

Please sign in to comment.