RTK-codegen-openapi -- Add formData flag on generation of endpoints usting RTK query and codegen-openapi

55 Views Asked by At

While using @rtk-query/codegen-openapi for API query generation, I've encountered a specific requirement for file upload endpoints. To accommodate file uploads using formData, it's necessary to include the formData: true flag within the query. is there any configuration option exists to automatically integrate this flag into the generated endpoints?

  endpoints: (build) => ({
    uploadFile: build.mutation<
      UploadFileResponse,
      UploadFileArg
    >({
      query: (queryArg) => ({
        url: `/files/upload`,
        method: "POST",
        body: queryArg,
        formData: true // need to add this flag on selected endpoints
      }),
    }),
  }),
  overrideExisting: false,
});
0

There are 0 best solutions below