Skip to content

Commit

Permalink
- Removed cross-blob dependency since node now supports this
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdikoomen committed Jan 6, 2022
1 parent 7086776 commit cfdbe48
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 19 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ classes in NodeJS).

```
npm install axios --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
```

Expand All @@ -481,7 +480,6 @@ in order to compile and run this client, you might need to install the `node-fet
```
npm install @types/[email protected] --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
```
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/templates/core/axios/request.hbs
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
11 changes: 10 additions & 1 deletion src/templates/core/functions/isBlob.hbs
Original file line number Diff line number Diff line change
@@ -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])
);
}
2 changes: 1 addition & 1 deletion test/e2e/v2.axios.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v2.babel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v2.fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v2.node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v2.xhr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/v3.axios.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v3.babel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/v3.fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/v3.node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v3.xhr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cfdbe48

Please sign in to comment.