orval icon indicating copy to clipboard operation
orval copied to clipboard

Option to export URLs

Open Maxim-Mazurok opened this issue 1 year ago • 0 comments

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!

Maxim-Mazurok avatar Jul 11 '23 05:07 Maxim-Mazurok