Skip to content

Commit

Permalink
fix: Fixing return type for response headers (#36)
Browse files Browse the repository at this point in the history
* fix return type

* update minor version

* regen types as per new return type

* fixing type for headers

* rename content to body

* major version upgrade
  • Loading branch information
vardanbansal-harness authored Oct 29, 2024
1 parent fa804fc commit 6747255
Show file tree
Hide file tree
Showing 46 changed files with 99 additions and 99 deletions.
8 changes: 4 additions & 4 deletions examples/output/github/hooks/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface FetcherOptions<TQueryParams = never, TBody = never, THeaderPara
const JSON_HEADERS = ['application/json'];

interface ResponseContainer<TResponse, TResponseHeaders> {
content: TResponse;
body: TResponse;
headers: TResponseHeaders;
}

Expand All @@ -20,7 +20,7 @@ export async function fetcher<
THeaderParams = HeadersInit,
>(
options: FetcherOptions<TQueryParams, TBody, THeaderParams>,
): Promise<ResponseContainer<TResponse, Record<string, any>>> {
): Promise<ResponseContainer<TResponse, Headers>> {
const { body, url, queryParams, headers, ...rest } = options;

const response = await fetch(url, {
Expand All @@ -39,8 +39,8 @@ export async function fetcher<

if (response.ok) {
return {
content: data,
headers: {},
body: data,
headers: response.headers,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export interface ReposListForAuthenticatedUserProps
}

export interface ReposListForAuthenticatedUserResponseContainer {
content: ReposListForAuthenticatedUserOkResponse;
headers: Record<string, any>;
body: ReposListForAuthenticatedUserOkResponse;
headers: Headers;
}

export function reposListForAuthenticatedUser(
Expand Down
8 changes: 4 additions & 4 deletions examples/output/petstore-openapi-v3.0/hooks/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface FetcherOptions<TQueryParams = never, TBody = never, THeaderPara
const JSON_HEADERS = ['application/json'];

interface ResponseContainer<TResponse, TResponseHeaders> {
content: TResponse;
body: TResponse;
headers: TResponseHeaders;
}

Expand All @@ -20,7 +20,7 @@ export async function fetcher<
THeaderParams = HeadersInit,
>(
options: FetcherOptions<TQueryParams, TBody, THeaderParams>,
): Promise<ResponseContainer<TResponse, Record<string, any>>> {
): Promise<ResponseContainer<TResponse, Headers>> {
const { body, url, queryParams, headers, ...rest } = options;

const response = await fetch(url, {
Expand All @@ -39,8 +39,8 @@ export async function fetcher<

if (response.ok) {
return {
content: data,
headers: {},
body: data,
headers: response.headers,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export interface AddPetProps extends Omit<FetcherOptions<unknown, AddPetRequestB
}

export interface AddPetResponseContainer {
content: AddPetOkResponse;
headers: Record<string, any>;
body: AddPetOkResponse;
headers: Headers;
}

export function addPet(props: AddPetProps): Promise<AddPetResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface CreateUserProps
}

export interface CreateUserResponseContainer {
content: CreateUserOkResponse;
headers: Record<string, any>;
body: CreateUserOkResponse;
headers: Headers;
}

export function createUser(props: CreateUserProps): Promise<CreateUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface CreateUsersWithListInputProps
}

export interface CreateUsersWithListInputResponseContainer {
content: CreateUsersWithListInputOkResponse;
headers: Record<string, any>;
body: CreateUsersWithListInputOkResponse;
headers: Headers;
}

export function createUsersWithListInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export interface DeleteOrderProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface DeleteOrderResponseContainer {
content: DeleteOrderOkResponse;
headers: Record<string, any>;
body: DeleteOrderOkResponse;
headers: Headers;
}

export function deleteOrder(props: DeleteOrderProps): Promise<DeleteOrderResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface DeletePetProps
Omit<FetcherOptions<unknown, unknown, DeletePetMutationHeaderParams>, 'url'> {}

export interface DeletePetResponseContainer {
content: DeletePetOkResponse;
headers: Record<string, any>;
body: DeletePetOkResponse;
headers: Headers;
}

export function deletePet(props: DeletePetProps): Promise<DeletePetResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface DeleteUserProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface DeleteUserResponseContainer {
content: DeleteUserOkResponse;
headers: Record<string, any>;
body: DeleteUserOkResponse;
headers: Headers;
}

export function deleteUser(props: DeleteUserProps): Promise<DeleteUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export interface FindPetsByStatusProps
}

export interface FindPetsByStatusResponseContainer {
content: FindPetsByStatusOkResponse;
headers: Record<string, any>;
body: FindPetsByStatusOkResponse;
headers: Headers;
}

export function findPetsByStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface FindPetsByTagsProps
}

export interface FindPetsByTagsResponseContainer {
content: FindPetsByTagsOkResponse;
headers: Record<string, any>;
body: FindPetsByTagsOkResponse;
headers: Headers;
}

export function findPetsByTags(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type GetInventoryErrorResponse = unknown;
export interface GetInventoryProps extends Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface GetInventoryResponseContainer {
content: GetInventoryOkResponse;
headers: Record<string, any>;
body: GetInventoryOkResponse;
headers: Headers;
}

export function getInventory(props: GetInventoryProps): Promise<GetInventoryResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface GetOrderByIdProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface GetOrderByIdResponseContainer {
content: GetOrderByIdOkResponse;
headers: Record<string, any>;
body: GetOrderByIdOkResponse;
headers: Headers;
}

export function getOrderById(props: GetOrderByIdProps): Promise<GetOrderByIdResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface GetPetByIdProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface GetPetByIdResponseContainer {
content: GetPetByIdOkResponse;
headers: Record<string, any>;
body: GetPetByIdOkResponse;
headers: Headers;
}

export function getPetById(props: GetPetByIdProps): Promise<GetPetByIdResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface GetUserByNameProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface GetUserByNameResponseContainer {
content: GetUserByNameOkResponse;
headers: Record<string, any>;
body: GetUserByNameOkResponse;
headers: Headers;
}

export function getUserByName(props: GetUserByNameProps): Promise<GetUserByNameResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export interface LoginUserProps
}

export interface LoginUserResponseContainer {
content: LoginUserOkResponse;
headers: Record<string, any>;
body: LoginUserOkResponse;
headers: Headers;
}

export function loginUser(props: LoginUserProps): Promise<LoginUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export type LogoutUserErrorResponse = unknown;
export interface LogoutUserProps extends Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface LogoutUserResponseContainer {
content: LogoutUserOkResponse;
headers: Record<string, any>;
body: LogoutUserOkResponse;
headers: Headers;
}

export function logoutUser(props: LogoutUserProps): Promise<LogoutUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface PlaceOrderProps
}

export interface PlaceOrderResponseContainer {
content: PlaceOrderOkResponse;
headers: Record<string, any>;
body: PlaceOrderOkResponse;
headers: Headers;
}

export function placeOrder(props: PlaceOrderProps): Promise<PlaceOrderResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export interface UpdatePetProps extends Omit<FetcherOptions<unknown, UpdatePetRe
}

export interface UpdatePetResponseContainer {
content: UpdatePetOkResponse;
headers: Record<string, any>;
body: UpdatePetOkResponse;
headers: Headers;
}

export function updatePet(props: UpdatePetProps): Promise<UpdatePetResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface UpdatePetWithFormProps
}

export interface UpdatePetWithFormResponseContainer {
content: UpdatePetWithFormOkResponse;
headers: Record<string, any>;
body: UpdatePetWithFormOkResponse;
headers: Headers;
}

export function updatePetWithForm(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export interface UpdateUserProps
}

export interface UpdateUserResponseContainer {
content: UpdateUserOkResponse;
headers: Record<string, any>;
body: UpdateUserOkResponse;
headers: Headers;
}

export function updateUser(props: UpdateUserProps): Promise<UpdateUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export interface UploadFileProps
}

export interface UploadFileResponseContainer {
content: UploadFileOkResponse;
headers: Record<string, any>;
body: UploadFileOkResponse;
headers: Headers;
}

export function uploadFile(props: UploadFileProps): Promise<UploadFileResponseContainer> {
Expand Down
8 changes: 4 additions & 4 deletions examples/output/petstore-swagger/hooks/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface FetcherOptions<TQueryParams = never, TBody = never, THeaderPara
const JSON_HEADERS = ['application/json'];

interface ResponseContainer<TResponse, TResponseHeaders> {
content: TResponse;
body: TResponse;
headers: TResponseHeaders;
}

Expand All @@ -21,7 +21,7 @@ export async function fetcher<
THeaderParams = HeadersInit,
>(
options: FetcherOptions<TQueryParams, TBody, THeaderParams>,
): Promise<ResponseContainer<TResponse, Record<string, any>>> {
): Promise<ResponseContainer<TResponse, Headers>> {
const { body, url, queryParams, headers, ...rest } = options;

const response = await fetch(url, {
Expand All @@ -40,8 +40,8 @@ export async function fetcher<

if (response.ok) {
return {
content: data,
headers: {},
body: data,
headers: response.headers,
};
}

Expand Down
4 changes: 2 additions & 2 deletions examples/output/petstore-swagger/hooks/useAddPetMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface AddPetProps extends Omit<FetcherOptions<unknown, AddPetRequestB
}

export interface AddPetResponseContainer {
content: AddPetOkResponse;
headers: Record<string, any>;
body: AddPetOkResponse;
headers: Headers;
}

export function addPet(props: AddPetProps): Promise<AddPetResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface CreateUserProps
}

export interface CreateUserResponseContainer {
content: CreateUserOkResponse;
headers: Record<string, any>;
body: CreateUserOkResponse;
headers: Headers;
}

export function createUser(props: CreateUserProps): Promise<CreateUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface CreateUsersWithArrayInputProps
}

export interface CreateUsersWithArrayInputResponseContainer {
content: CreateUsersWithArrayInputOkResponse;
headers: Record<string, any>;
body: CreateUsersWithArrayInputOkResponse;
headers: Headers;
}

export function createUsersWithArrayInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface CreateUsersWithListInputProps
}

export interface CreateUsersWithListInputResponseContainer {
content: CreateUsersWithListInputOkResponse;
headers: Record<string, any>;
body: CreateUsersWithListInputOkResponse;
headers: Headers;
}

export function createUsersWithListInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface DeleteOrderProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface DeleteOrderResponseContainer {
content: DeleteOrderOkResponse;
headers: Record<string, any>;
body: DeleteOrderOkResponse;
headers: Headers;
}

export function deleteOrder(props: DeleteOrderProps): Promise<DeleteOrderResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export interface DeletePetProps
Omit<FetcherOptions<unknown, unknown, DeletePetMutationHeaderParams>, 'url'> {}

export interface DeletePetResponseContainer {
content: DeletePetOkResponse;
headers: Record<string, any>;
body: DeletePetOkResponse;
headers: Headers;
}

export function deletePet(props: DeletePetProps): Promise<DeletePetResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export interface DeleteUserProps
Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export interface DeleteUserResponseContainer {
content: DeleteUserOkResponse;
headers: Record<string, any>;
body: DeleteUserOkResponse;
headers: Headers;
}

export function deleteUser(props: DeleteUserProps): Promise<DeleteUserResponseContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export interface FindPetsByStatusProps
}

export interface FindPetsByStatusResponseContainer {
content: FindPetsByStatusOkResponse;
headers: Record<string, any>;
body: FindPetsByStatusOkResponse;
headers: Headers;
}

export function findPetsByStatus(
Expand Down
Loading

0 comments on commit 6747255

Please sign in to comment.