From cfdbe48df30d9b6d8873bb8807868cffac8f57bd Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Thu, 6 Jan 2022 15:18:16 +0100 Subject: [PATCH] - Removed cross-blob dependency since node now supports this --- README.md | 2 -- package.json | 1 - src/templates/core/axios/request.hbs | 1 - src/templates/core/functions/isBlob.hbs | 11 ++++++++++- test/e2e/v2.axios.spec.js | 2 +- test/e2e/v2.babel.spec.js | 2 +- test/e2e/v2.fetch.spec.js | 2 +- test/e2e/v2.node.spec.js | 2 +- test/e2e/v2.xhr.spec.js | 2 +- test/e2e/v3.axios.spec.js | 4 ++-- test/e2e/v3.babel.spec.js | 2 +- test/e2e/v3.fetch.spec.js | 4 ++-- test/e2e/v3.node.spec.js | 4 ++-- test/e2e/v3.xhr.spec.js | 2 +- test/index.js | 2 +- 15 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 8a32b809..ec076f73 100644 --- a/README.md +++ b/README.md @@ -457,7 +457,6 @@ classes in NodeJS). ``` npm install axios --save-dev -npm install cross-blob@2.x --save-dev npm install form-data@4.x --save-dev ``` @@ -481,7 +480,6 @@ in order to compile and run this client, you might need to install the `node-fet ``` npm install @types/node-fetch@2.x --save-dev npm install abort-controller@3.x --save-dev -npm install cross-blob@2.x --save-dev npm install form-data@4.x --save-dev npm install node-fetch@2.x --save-dev ``` diff --git a/package.json b/package.json index 27ebbc9f..0a17d863 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "axios": "^0.24.0", "camelcase": "^6.3.0", "commander": "^8.3.0", - "cross-blob": "^2.0.1", "form-data": "^4.0.0", "handlebars": "^4.7.6", "json-schema-ref-parser": "^9.0.7", diff --git a/src/templates/core/axios/request.hbs b/src/templates/core/axios/request.hbs index fd5bdbfe..110186d5 100644 --- a/src/templates/core/axios/request.hbs +++ b/src/templates/core/axios/request.hbs @@ -1,7 +1,6 @@ {{>header}} import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; -import Blob from 'cross-blob' import FormData from 'form-data'; import { ApiError } from './ApiError'; diff --git a/src/templates/core/functions/isBlob.hbs b/src/templates/core/functions/isBlob.hbs index 314c6b3b..4a27d5a9 100644 --- a/src/templates/core/functions/isBlob.hbs +++ b/src/templates/core/functions/isBlob.hbs @@ -1,3 +1,12 @@ function isBlob(value: any): value is Blob { - return value instanceof Blob; + return ( + typeof value === 'object' && + typeof value.type === 'string' && + typeof value.stream === 'function' && + typeof value.arrayBuffer === 'function' && + typeof value.constructor === 'function' && + typeof value.constructor.name === 'string' && + /^(Blob|File)$/.test(value.constructor.name) && + /^(Blob|File)$/.test(value[Symbol.toStringTag]) + ); } diff --git a/test/e2e/v2.axios.spec.js b/test/e2e/v2.axios.spec.js index ce6ca66e..4da91e94 100644 --- a/test/e2e/v2.axios.spec.js +++ b/test/e2e/v2.axios.spec.js @@ -24,7 +24,7 @@ describe('v2.node', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); - it('complexService', async () => { + it('supports complex params', async () => { const { ComplexService } = require('./generated/v2/axios/index.js'); const result = await ComplexService.complexTypes({ first: { diff --git a/test/e2e/v2.babel.spec.js b/test/e2e/v2.babel.spec.js index 64568cfa..7151dd05 100644 --- a/test/e2e/v2.babel.spec.js +++ b/test/e2e/v2.babel.spec.js @@ -30,7 +30,7 @@ describe('v2.babel', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ diff --git a/test/e2e/v2.fetch.spec.js b/test/e2e/v2.fetch.spec.js index 75e560a9..032b5740 100644 --- a/test/e2e/v2.fetch.spec.js +++ b/test/e2e/v2.fetch.spec.js @@ -30,7 +30,7 @@ describe('v2.fetch', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ diff --git a/test/e2e/v2.node.spec.js b/test/e2e/v2.node.spec.js index c8b3920d..8bedadcf 100644 --- a/test/e2e/v2.node.spec.js +++ b/test/e2e/v2.node.spec.js @@ -24,7 +24,7 @@ describe('v2.node', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); - it('complexService', async () => { + it('supports complex params', async () => { const { ComplexService } = require('./generated/v2/node/index.js'); const result = await ComplexService.complexTypes({ first: { diff --git a/test/e2e/v2.xhr.spec.js b/test/e2e/v2.xhr.spec.js index b7f2c09e..57523f1e 100644 --- a/test/e2e/v2.xhr.spec.js +++ b/test/e2e/v2.xhr.spec.js @@ -31,7 +31,7 @@ describe('v2.xhr', () => { expect(result.headers.authorization).toBe('Bearer MY_TOKEN'); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ diff --git a/test/e2e/v3.axios.spec.js b/test/e2e/v3.axios.spec.js index 3814891f..4c669b9e 100644 --- a/test/e2e/v3.axios.spec.js +++ b/test/e2e/v3.axios.spec.js @@ -35,7 +35,7 @@ describe('v3.node', () => { expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); - it('complexService', async () => { + it('supports complex params', async () => { const { ComplexService } = require('./generated/v3/axios/index.js'); const result = await ComplexService.complexTypes({ first: { @@ -47,7 +47,7 @@ describe('v3.node', () => { expect(result).toBeDefined(); }); - it('formData', async () => { + it('supports form data', async () => { const { ParametersService } = require('./generated/v3/axios/index.js'); const result = await ParametersService.callWithParameters( 'valueHeader', diff --git a/test/e2e/v3.babel.spec.js b/test/e2e/v3.babel.spec.js index 26e7268e..0a546ddf 100644 --- a/test/e2e/v3.babel.spec.js +++ b/test/e2e/v3.babel.spec.js @@ -43,7 +43,7 @@ describe('v3.babel', () => { expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ diff --git a/test/e2e/v3.fetch.spec.js b/test/e2e/v3.fetch.spec.js index d0fc1342..d2ebd31d 100644 --- a/test/e2e/v3.fetch.spec.js +++ b/test/e2e/v3.fetch.spec.js @@ -43,7 +43,7 @@ describe('v3.fetch', () => { expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ @@ -57,7 +57,7 @@ describe('v3.fetch', () => { expect(result).toBeDefined(); }); - it('formData', async () => { + it('support form data', async () => { const result = await browser.evaluate(async () => { const { ParametersService } = window.api; return await ParametersService.callWithParameters( diff --git a/test/e2e/v3.node.spec.js b/test/e2e/v3.node.spec.js index 2e506582..bb3ce5ac 100644 --- a/test/e2e/v3.node.spec.js +++ b/test/e2e/v3.node.spec.js @@ -35,7 +35,7 @@ describe('v3.node', () => { expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); - it('complexService', async () => { + it('supports complex params', async () => { const { ComplexService } = require('./generated/v3/node/index.js'); const result = await ComplexService.complexTypes({ first: { @@ -47,7 +47,7 @@ describe('v3.node', () => { expect(result).toBeDefined(); }); - it('formData', async () => { + it('support form data', async () => { const { ParametersService } = require('./generated/v3/node/index.js'); const result = await ParametersService.callWithParameters( 'valueHeader', diff --git a/test/e2e/v3.xhr.spec.js b/test/e2e/v3.xhr.spec.js index 16621498..3354115b 100644 --- a/test/e2e/v3.xhr.spec.js +++ b/test/e2e/v3.xhr.spec.js @@ -43,7 +43,7 @@ describe('v3.xhr', () => { expect(result.headers.authorization).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); }); - it('complexService', async () => { + it('supports complex params', async () => { const result = await browser.evaluate(async () => { const { ComplexService } = window.api; return await ComplexService.complexTypes({ diff --git a/test/index.js b/test/index.js index 441a163b..65bc35a3 100644 --- a/test/index.js +++ b/test/index.js @@ -7,7 +7,7 @@ async function generate(input, output) { await OpenAPI.generate({ input, output, - httpClient: OpenAPI.HttpClient.FETCH, + httpClient: OpenAPI.HttpClient.AXIOS, useOptions: false, useUnionTypes: false, exportCore: true,