@hey-api/openapi-ts 0.87.4 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,6 +123,7 @@ export const createClient = (config: Config = {}): Client => {
123
123
  const applyRequestInterceptors = async (
124
124
  request: Request,
125
125
  opts: ResolvedRequestOptions,
126
+ body: BodyInit | null | undefined,
126
127
  ) => {
127
128
  for (const fn of interceptors.request.fns) {
128
129
  if (fn) {
@@ -136,6 +137,18 @@ export const createClient = (config: Config = {}): Client => {
136
137
  // body comes only from getValidRequestBody(options)
137
138
  // reflect signal if present
138
139
  opts.signal = (request as any).signal as AbortSignal | undefined;
140
+
141
+ // When body is FormData, remove Content-Type header to avoid boundary mismatch.
142
+ // Note: We already delete Content-Type in resolveOptions for FormData, but the
143
+ // Request constructor (line 175) re-adds it with an auto-generated boundary.
144
+ // Since we pass the original FormData (not the Request's body) to ofetch, and
145
+ // ofetch will generate its own boundary, we must remove the Request's Content-Type
146
+ // to let ofetch set the correct one. Otherwise the boundary in the header won't
147
+ // match the boundary in the actual multipart body sent by ofetch.
148
+ if (typeof FormData !== 'undefined' && body instanceof FormData) {
149
+ opts.headers.delete('Content-Type');
150
+ }
151
+
139
152
  return request;
140
153
  };
141
154
 
@@ -174,7 +187,7 @@ export const createClient = (config: Config = {}): Client => {
174
187
  };
175
188
  let request = new Request(url, requestInit);
176
189
 
177
- request = await applyRequestInterceptors(request, opts);
190
+ request = await applyRequestInterceptors(request, opts, networkBody);
178
191
  const finalUrl = request.url;
179
192
 
180
193
  // build ofetch options and perform the request (.raw keeps the Response)
@@ -233,7 +246,7 @@ export const createClient = (config: Config = {}): Client => {
233
246
  method,
234
247
  onRequest: async (url, init) => {
235
248
  let request = new Request(url, init);
236
- request = await applyRequestInterceptors(request, opts);
249
+ request = await applyRequestInterceptors(request, opts, networkBody);
237
250
  return request;
238
251
  },
239
252
  serializedBody: networkBody as BodyInit | null | undefined,