openapi-codegen icon indicating copy to clipboard operation
openapi-codegen copied to clipboard

[Feature Request] Provide separate endpoint data variables

Open badsyntax opened this issue 8 months ago • 0 comments

Using generateReactQueryComponents(), the following is generated:

export const fetchDeleteFile = (
  variables: DeleteFileVariables,
  signal?: AbortSignal,
) =>
  fetch<
    string,
    DeleteFileError,
    undefined,
    DeleteFileHeaders,
    {},
    DeleteFilePathParams
  >({
    url: '/v1/activities/file/{blobName}',
    method: 'delete',
    ...variables,
    signal,
  });

In the above code, there's no way for me to access the URL (/v1/activities/file/{blobName}) for that endpoint.

It would be very useful if we could do this instead:

export const deleteFileOperation = {
  url: '/v1/activities/file/{blobName}',
  method: 'delete',
};

export const fetchDeleteFile = (
  variables: DeleteFileVariables,
  signal?: AbortSignal,
) =>
  fetch<
    string,
    DeleteFileError,
    undefined,
    DeleteFileHeaders,
    {},
    DeleteFilePathParams
  >({
    ...deleteFileOperation,
    ...variables,
    signal,
  });

This allows me to access the endpoint metadata.

Use Case:

I need to build a custom react-query hook that uses XMLHttpRequest (for file uploads), but i have to hard code the endpoint URL, instead of referencing the URL in generated code.

badsyntax avatar Jun 11 '25 05:06 badsyntax