Skip to content

fix: export type Client for FunctionalApiClient #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import ts from "typescript";
import type { TsGenerator } from "../../../api";

export const create = (factory: TsGenerator.Factory.Type) => {
return factory.TypeAliasDeclaration.create({
export: true,
name: "Client",
type: factory.TypeReferenceNode.create({
name: `ReturnType<typeof createClient>`,
export const create = (factory: TsGenerator.Factory.Type): ts.TypeAliasDeclaration[] => {
return [
factory.TypeAliasDeclaration.create({
name: "ClientFunction<RequestOption>",
type: factory.TypeReferenceNode.create({
name: `typeof createClient<RequestOption>`,
})
}),
factory.TypeAliasDeclaration.create({
export: true,
name: "Client<RequestOption>",
type: factory.TypeReferenceNode.create({
name: `ReturnType<ClientFunction<RequestOption>>`,
})
})
})
]
};
5 changes: 4 additions & 1 deletion src/code-templates/functional-api-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export const generator: CodeGenerator.GenerateFunction<Option> = (

const apiClientStatement = FunctionalApiClient.create(factory, codeGeneratorParamsList, option || {});
statements.push(apiClientStatement);
statements.push(ClientTypeDefinition.create(factory));
ClientTypeDefinition.create(factory).forEach(statement => {
statements.push(statement);
})

return statements;
};
2 changes: 1 addition & 1 deletion src/meta.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const Name = "@himenon/openapi-typescript-code-generator";
export const Version = "0.22.0";
export const Version = "0.22.1";
Original file line number Diff line number Diff line change
Expand Up @@ -3923,6 +3923,7 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface ApiClient<RequestOption> {
export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>, baseUrl: string) => {
return {};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -56556,6 +56556,7 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -274,7 +275,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -308,6 +310,7 @@ export interface ApiClient<RequestOption> {
export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>, baseUrl: string) => {
return {};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -548,7 +549,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -1036,7 +1038,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -1093,7 +1096,8 @@ export interface ApiClient<RequestOption> {
export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>, baseUrl: string) => {
return {};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -1231,7 +1235,8 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;

Expand Down Expand Up @@ -1377,6 +1382,7 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const createClient = <RequestOption>(apiClient: ApiClient<RequestOption>,
}
};
};
export type Client = ReturnType<typeof createClient>;
type ClientFunction<RequestOption> = typeof createClient<RequestOption>;
export type Client<RequestOption> = ReturnType<ClientFunction<RequestOption>>;
"
`;