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

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3459 from LeiCraft/fix/binary-object-handling-in-multipart-form-data-in-nuxt-client

Fix binary object handling in multipart/form-data (File / Blob) when using nuxt

authored by

Lubos and committed by
GitHub
12c76b8b 7ef9332f

+88 -1
+5
.changeset/selfish-jokes-exercise.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + **client(@hey-api/nuxt)**: fix: do not unwrap blob values
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/import-file-extension-ts/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-node16-sdk/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/utils.gen.ts
··· 346 346 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 347 347 } 348 348 349 + if (value instanceof Blob) { 350 + return value as UnwrapRefs<T>; 351 + } 352 + 349 353 if (Array.isArray(value)) { 350 354 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 351 355 }
+31 -1
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/__tests__/utils.test.ts
··· 1 1 import type { Auth } from '../../client-core/bundle/auth'; 2 - import { mergeInterceptors, setAuthParams } from '../bundle/utils'; 2 + import { mergeInterceptors, setAuthParams, unwrapRefs } from '../bundle/utils'; 3 + 4 + describe('unwrapRefs', () => { 5 + it('returns Blob as-is', () => { 6 + const blob = new Blob(['test content'], { type: 'text/plain' }); 7 + const result = unwrapRefs(blob); 8 + expect(result).toBe(blob); 9 + }); 10 + 11 + it('preserves Blob in object', () => { 12 + const blob = new Blob(['test content'], { type: 'application/json' }); 13 + const input = { file: blob, name: 'test' }; 14 + const result = unwrapRefs(input); 15 + expect(result.file).toBe(blob); 16 + expect(result.name).toBe('test'); 17 + }); 18 + 19 + it('preserves Blob in array', () => { 20 + const blob = new Blob(['test content'], { type: 'image/png' }); 21 + const input = [blob, 'text']; 22 + const result = unwrapRefs(input); 23 + expect(result[0]).toBe(blob); 24 + expect(result[1]).toBe('text'); 25 + }); 26 + 27 + it('preserves File (extends Blob) as-is', () => { 28 + const file = new File(['test content'], 'test.txt', { type: 'text/plain' }); 29 + const result = unwrapRefs(file); 30 + expect(result).toBe(file); 31 + }); 32 + }); 3 33 4 34 describe('mergeInterceptors', () => { 5 35 it('handles no arguments', () => {
+4
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/utils.ts
··· 344 344 return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>; 345 345 } 346 346 347 + if (value instanceof Blob) { 348 + return value as UnwrapRefs<T>; 349 + } 350 + 347 351 if (Array.isArray(value)) { 348 352 return value.map((item) => unwrapRefs(item)) as UnwrapRefs<T>; 349 353 }