Skip to content
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

Export request/response types from generated client #1219

Closed
bobgubko opened this issue Oct 9, 2023 · 5 comments
Closed

Export request/response types from generated client #1219

bobgubko opened this issue Oct 9, 2023 · 5 comments
Labels
question Further information is requested

Comments

@bobgubko
Copy link

bobgubko commented Oct 9, 2023

Is there a way to add export to request and response types to the client generated via Integration?

@RobinTail RobinTail added the question Further information is requested label Oct 9, 2023
@RobinTail
Copy link
Owner

It seems to that they are already exported, @bobgubko

export interface Input extends Record<MethodPath, any> {
"get /v1/user/retrieve": GetV1UserRetrieveInput;
"post /v1/user/:id": PostV1UserIdInput;
"get /v1/user/list": GetV1UserListInput;
"get /v1/avatar/send": GetV1AvatarSendInput;
"get /v1/avatar/stream": GetV1AvatarStreamInput;
"post /v1/avatar/upload": PostV1AvatarUploadInput;
}
export interface Response extends Record<MethodPath, any> {
"get /v1/user/retrieve": GetV1UserRetrieveResponse;
"post /v1/user/:id": PostV1UserIdResponse;
"get /v1/user/list": GetV1UserListResponse;
"get /v1/avatar/send": GetV1AvatarSendResponse;
"get /v1/avatar/stream": GetV1AvatarStreamResponse;
"post /v1/avatar/upload": PostV1AvatarUploadResponse;
}

Or maybe I don't understand what you mean.
Please clarify.

@bobgubko
Copy link
Author

bobgubko commented Oct 9, 2023

So if I need to access GetV1UserRetrieveResponse, I can access it as Response["get /v1/user/retrieve"]?

@RobinTail
Copy link
Owner

exactly, @bobgubko

@RobinTail
Copy link
Owner

@bobgubko , that's how Provider type works.
You can make your own helper similarly.

export type Provider = <M extends Method, P extends Path>(
method: M,
path: P,
params: Input[`${M} ${P}`],
) => Promise<Response[`${M} ${P}`]>;

@bobgubko
Copy link
Author

bobgubko commented Oct 9, 2023

Thanks for clarifying!

@bobgubko bobgubko closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants