Skip to content

Commit

Permalink
Make empty methods optional, add examples typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Oct 5, 2023
1 parent 04a024a commit bbd21db
Show file tree
Hide file tree
Showing 29 changed files with 14,200 additions and 14,064 deletions.
5 changes: 0 additions & 5 deletions .changeset/beige-ligers-tell.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/rich-poems-swim.md

This file was deleted.

42 changes: 21 additions & 21 deletions packages/openapi-fetch/examples/nextjs/lib/api/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export interface paths {
* @description Returns a a list of breeds
*/
get: operations["getBreeds"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/fact": {
parameters: {
Expand All @@ -36,13 +36,13 @@ export interface paths {
* @description Returns a random fact
*/
get: operations["getRandomFact"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/facts": {
parameters: {
Expand All @@ -56,13 +56,13 @@ export interface paths {
* @description Returns a a list of facts
*/
get: operations["getFacts"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
Expand Down
42 changes: 21 additions & 21 deletions packages/openapi-fetch/examples/react-query/src/lib/api/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export interface paths {
* @description Returns a a list of breeds
*/
get: operations["getBreeds"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/fact": {
parameters: {
Expand All @@ -36,13 +36,13 @@ export interface paths {
* @description Returns a random fact
*/
get: operations["getRandomFact"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/facts": {
parameters: {
Expand All @@ -56,13 +56,13 @@ export interface paths {
* @description Returns a a list of facts
*/
get: operations["getFacts"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
Expand Down
42 changes: 21 additions & 21 deletions packages/openapi-fetch/examples/sveltekit/src/lib/api/v1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export interface paths {
* @description Returns a a list of breeds
*/
get: operations["getBreeds"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/fact": {
parameters: {
Expand All @@ -36,13 +36,13 @@ export interface paths {
* @description Returns a random fact
*/
get: operations["getRandomFact"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/facts": {
parameters: {
Expand All @@ -56,13 +56,13 @@ export interface paths {
* @description Returns a a list of facts
*/
get: operations["getFacts"];
put: never;
post: never;
delete: never;
options: never;
head: never;
patch: never;
trace: never;
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
Expand Down
8 changes: 4 additions & 4 deletions packages/openapi-fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export interface EmptyParameters {
}

export type ParamsOption<T> = T extends { parameters: any }
? T["parameters"] extends EmptyParameters
? DefaultParamsOption
: { params: NonNullable<T["parameters"]> }
: DefaultParamsOption;
? HasRequiredKeys<T["parameters"]> extends never
? { params?: T["parameters"] }
: { params: T["parameters"] }
: never;

export type RequestBodyOption<T> = OperationRequestBodyContent<T> extends never
? { body?: never }
Expand Down
Loading

0 comments on commit bbd21db

Please sign in to comment.