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

feat(functional): make the functional api client a pure function. #103

Closed
wants to merge 1 commit into from

Conversation

hrsh7th
Copy link
Contributor

@hrsh7th hrsh7th commented Mar 27, 2023

Summary

Currently, the functional api client does not support tree-shaking.
This PR solves the problem.

Fixes #97

Test Plan

I'll update the snapshot testing.

Example output

...

export const RolloutService_SetRolloutImage = <RequestOption>(apiClient: ApiClient<RequestOption>, params: Params$RolloutService_SetRolloutImage, option?: RequestOption): Promise<Response$RolloutService_SetRolloutImage$Status$200["application/json"]> => {
    const url = `/api/v1/rollouts/`;
    const headers = {
        "Content-Type": "application/json",
        Accept: "application/json"
    };
    return apiClient.request("PUT", url, headers, params.requestBody, undefined, option);
};
export const RolloutService_UndoRollout = <RequestOption>(apiClient: ApiClient<RequestOption>, params: Params$RolloutService_UndoRollout, option?: RequestOption): Promise<Response$RolloutService_UndoRollout$Status$200["application/json"]> => {
    const url = `/api/v1/rollouts/`;
    const headers = {
        "Content-Type": "application/json",
        Accept: "application/json"
    };
    return apiClient.request("PUT", url, headers, params.requestBody, undefined, option);
};
export const RolloutService_Version = <RequestOption>(apiClient: ApiClient<RequestOption>, option?: RequestOption): Promise<Response$RolloutService_Version$Status$200["application/json"]> => {
    const url = `/api/v1/version`;
    const headers = {
        Accept: "application/json"
    };
    return apiClient.request("GET", url, headers, undefined, undefined, option);
};

...

I don't know why but the url variable is corrupted now...

}),
function: Utils.generateTemplateExpression(factory, urlTemplate),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand the reason but this code isn't worked.

The class part works fine but function part will be wrong template string.

name: "RequestOption",
}),
);
typeParameters.push(...methodTypeParameters(factory, params));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each functions are now accept the apiClient argument and RequestOption type argument.

],
}),
}),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the apiClient argument was added here.

declarations: [
factory.VariableDeclaration.create({
name: params.convertedParams.functionName,
initializer: ArrowFunction.create(factory, params, option),
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the functional api client will be list of ArrowFunctions now.

@Himenon
Copy link
Owner

Himenon commented Apr 2, 2023

@hrsh7th
Thank you for your cooperation. We have created #109 based on this idea, which has been committed as Co-authored, so please check it out.

@hrsh7th
Copy link
Contributor Author

hrsh7th commented Apr 2, 2023

Fixed by #109. Closing.

@hrsh7th hrsh7th closed this Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do you have the plan to suppor tree-shaking?
2 participants