Skip to content

Commit ba0b79d

Browse files
committed
Fixed issue ferdikoomen#782
1 parent 35bda10 commit ba0b79d

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

src/openApi/v2/parser/getMappedType.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getMappedType } from './getMappedType';
22

33
describe('getMappedType', () => {
44
it('should map types to the basics', () => {
5-
expect(getMappedType('File')).toEqual('File');
6-
expect(getMappedType('file')).toEqual('File');
5+
expect(getMappedType('File')).toEqual('binary');
6+
expect(getMappedType('file')).toEqual('binary');
77
expect(getMappedType('string')).toEqual('string');
88
expect(getMappedType('date')).toEqual('string');
99
expect(getMappedType('date-time')).toEqual('string');

src/openApi/v2/parser/getMappedType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const TYPE_MAPPINGS = new Map<string, string>([
2-
['File', 'File'],
3-
['file', 'File'],
2+
['File', 'binary'],
3+
['file', 'binary'],
44
['any', 'any'],
55
['object', 'any'],
66
['array', 'any[]'],
@@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map<string, string>([
2727
*/
2828
export function getMappedType(type: string, format?: string): string | undefined {
2929
if (format === 'binary') {
30-
return 'File';
30+
return 'binary';
3131
}
3232
return TYPE_MAPPINGS.get(type);
3333
}

src/openApi/v3/parser/getMappedType.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getMappedType } from './getMappedType';
22

33
describe('getMappedType', () => {
44
it('should map types to the basics', () => {
5-
expect(getMappedType('File')).toEqual('File');
6-
expect(getMappedType('file')).toEqual('File');
5+
expect(getMappedType('File')).toEqual('binary');
6+
expect(getMappedType('file')).toEqual('binary');
77
expect(getMappedType('string')).toEqual('string');
88
expect(getMappedType('date')).toEqual('string');
99
expect(getMappedType('date-time')).toEqual('string');

src/openApi/v3/parser/getMappedType.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const TYPE_MAPPINGS = new Map<string, string>([
2-
['File', 'File'],
3-
['file', 'File'],
2+
['File', 'binary'],
3+
['file', 'binary'],
44
['any', 'any'],
55
['object', 'any'],
66
['array', 'any[]'],
@@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map<string, string>([
2727
*/
2828
export function getMappedType(type: string, format?: string): string | undefined {
2929
if (format === 'binary') {
30-
return 'File';
30+
return 'binary';
3131
}
3232
return TYPE_MAPPINGS.get(type);
3333
}

src/templates/partials/base.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{~#equals base 'File'~}}
1+
{{~#equals base 'binary'~}}
22
{{~#equals @root.httpClient 'fetch'}}Blob{{/equals~}}
33
{{~#equals @root.httpClient 'xhr'}}Blob{{/equals~}}
44
{{~#equals @root.httpClient 'axios'}}Blob{{/equals~}}

test/__snapshots__/index.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ export const $ModelWithArray = {
15201520
propWithFile: {
15211521
type: 'array',
15221522
contains: {
1523-
type: 'File',
1523+
type: 'binary',
15241524
},
15251525
},
15261526
propWithNumber: {
@@ -1886,7 +1886,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = `
18861886
/* tslint:disable */
18871887
/* eslint-disable */
18881888
export const $SimpleFile = {
1889-
type: 'File',
1889+
type: 'binary',
18901890
};"
18911891
`;
18921892

@@ -4416,7 +4416,7 @@ export const $ModelWithArray = {
44164416
propWithFile: {
44174417
type: 'array',
44184418
contains: {
4419-
type: 'File',
4419+
type: 'binary',
44204420
},
44214421
},
44224422
propWithNumber: {
@@ -4799,7 +4799,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = `
47994799
/* tslint:disable */
48004800
/* eslint-disable */
48014801
export const $SimpleFile = {
4802-
type: 'File',
4802+
type: 'binary',
48034803
};"
48044804
`;
48054805

yarn.lock

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,11 +1363,6 @@
13631363
jest-diff "^27.0.0"
13641364
pretty-format "^27.0.0"
13651365

1366-
1367-
version "4.0.4"
1368-
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.4.tgz#cc38781257612581a1a0eb25f1709d2b06812fce"
1369-
integrity sha512-AuHubXUmg0AzkXH0Mx6sIxeY/1C110mm/EkE/gB1sTRz3h2dao2W/63q42SlVST+lICxz5Oki2hzYA6+KnnieQ==
1370-
13711366
"@types/json-schema@^7.0.6", "@types/json-schema@^7.0.9":
13721367
version "7.0.9"
13731368
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
@@ -3539,7 +3534,7 @@ [email protected], js-yaml@^3.13.1:
35393534
argparse "^1.0.7"
35403535
esprima "^4.0.0"
35413536

3542-
js-yaml@4.1.0, js-yaml@^4.1.0:
3537+
js-yaml@^4.1.0:
35433538
version "4.1.0"
35443539
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
35453540
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==

0 commit comments

Comments
 (0)