orval
orval copied to clipboard
Option to export URLs
I have this:
export const monitoringRequestsGETMonitoringRequests = (
collectionPK: MaybeRef<string | undefined | null>,
options?: AxiosRequestConfig
): Promise<AxiosResponse<ResponseMonitoringRequestModel[]>> => {
return axios.default.get(`/api/v1/monitoring-requests/${encodeURIComponent(String(unref(collectionPK)))}`, options);
};
What I need is to have that URL string exported, because I need to make it a clickable link as opposed to a request.
So ideally I'm looking for something like this:
export const monitoringRequestsGETMonitoringRequestsURL = (
collectionPK: MaybeRef<string | undefined | null>
): string => {
return `/api/v1/monitoring-requests/${encodeURIComponent(String(unref(collectionPK)))}`;
};
export const monitoringRequestsGETMonitoringRequests = (
collectionPK: MaybeRef<string | undefined | null>,
options?: AxiosRequestConfig
): Promise<AxiosResponse<ResponseMonitoringRequestModel[]>> => {
return axios.default.get(monitoringRequestsGETMonitoringRequestsURL(collectionPK), options);
};
So that I can do something like <a href={monitoringRequestsGETMonitoringRequestsURL(bla)}>see diff</a>
This is probably unconventional, and is a requirement for internal tool.
But this will also come in quite handy when writing handlers for tests in MSW. Right now I have to manually provide those URLs and if API changes - my MSW handlers will not know about it. Perhaps it's out of scope of this package, but still putting it out there, perhaps someone would also want that!