fork of hey-api/openapi-ts because I need some additional things

Update all examples and snapshots with FormData fix

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+180 -24
+15 -2
examples/openapi-ts-ofetch/src/client/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-false/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-number/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-strict/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/base-url-string/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/clean-false/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/default/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/import-file-extension-ts/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-optional/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/sdk-client-required/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-ofetch/tsconfig-nodenext-sdk/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,
+15 -2
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-ofetch/client/client.gen.ts
··· 125 125 const applyRequestInterceptors = async ( 126 126 request: Request, 127 127 opts: ResolvedRequestOptions, 128 + body: BodyInit | null | undefined, 128 129 ) => { 129 130 for (const fn of interceptors.request.fns) { 130 131 if (fn) { ··· 138 139 // body comes only from getValidRequestBody(options) 139 140 // reflect signal if present 140 141 opts.signal = (request as any).signal as AbortSignal | undefined; 142 + 143 + // When body is FormData, remove Content-Type header to avoid boundary mismatch. 144 + // Note: We already delete Content-Type in resolveOptions for FormData, but the 145 + // Request constructor (line 175) re-adds it with an auto-generated boundary. 146 + // Since we pass the original FormData (not the Request's body) to ofetch, and 147 + // ofetch will generate its own boundary, we must remove the Request's Content-Type 148 + // to let ofetch set the correct one. Otherwise the boundary in the header won't 149 + // match the boundary in the actual multipart body sent by ofetch. 150 + if (typeof FormData !== 'undefined' && body instanceof FormData) { 151 + opts.headers.delete('Content-Type'); 152 + } 153 + 141 154 return request; 142 155 }; 143 156 ··· 176 189 }; 177 190 let request = new Request(url, requestInit); 178 191 179 - request = await applyRequestInterceptors(request, opts); 192 + request = await applyRequestInterceptors(request, opts, networkBody); 180 193 const finalUrl = request.url; 181 194 182 195 // build ofetch options and perform the request (.raw keeps the Response) ··· 235 248 method, 236 249 onRequest: async (url, init) => { 237 250 let request = new Request(url, init); 238 - request = await applyRequestInterceptors(request, opts); 251 + request = await applyRequestInterceptors(request, opts, networkBody); 239 252 return request; 240 253 }, 241 254 serializedBody: networkBody as BodyInit | null | undefined,