- Removed cross-blob dependency since node now supports this

This commit is contained in:
Ferdi Koomen 2022-01-06 15:18:16 +01:00
parent 708677684d
commit cfdbe48df3
15 changed files with 24 additions and 19 deletions

View File

@ -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
```

View File

@ -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",

View File

@ -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';

View File

@ -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])
);
}

View File

@ -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: {

View File

@ -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({

View File

@ -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({

View File

@ -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: {

View File

@ -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({

View File

@ -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',

View File

@ -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({

View File

@ -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(

View File

@ -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',

View File

@ -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({

View File

@ -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,