diff --git a/src/openApi/v2/parser/getMappedType.spec.ts b/src/openApi/v2/parser/getMappedType.spec.ts index 7b40748a..8821b440 100644 --- a/src/openApi/v2/parser/getMappedType.spec.ts +++ b/src/openApi/v2/parser/getMappedType.spec.ts @@ -2,8 +2,8 @@ import { getMappedType } from './getMappedType'; describe('getMappedType', () => { it('should map types to the basics', () => { - expect(getMappedType('File')).toEqual('File'); - expect(getMappedType('file')).toEqual('File'); + expect(getMappedType('File')).toEqual('binary'); + expect(getMappedType('file')).toEqual('binary'); expect(getMappedType('string')).toEqual('string'); expect(getMappedType('date')).toEqual('string'); expect(getMappedType('date-time')).toEqual('string'); diff --git a/src/openApi/v2/parser/getMappedType.ts b/src/openApi/v2/parser/getMappedType.ts index f0ccb3ee..a7322756 100644 --- a/src/openApi/v2/parser/getMappedType.ts +++ b/src/openApi/v2/parser/getMappedType.ts @@ -1,6 +1,6 @@ const TYPE_MAPPINGS = new Map([ - ['File', 'File'], - ['file', 'File'], + ['File', 'binary'], + ['file', 'binary'], ['any', 'any'], ['object', 'any'], ['array', 'any[]'], @@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map([ */ export function getMappedType(type: string, format?: string): string | undefined { if (format === 'binary') { - return 'File'; + return 'binary'; } return TYPE_MAPPINGS.get(type); } diff --git a/src/openApi/v3/parser/getMappedType.spec.ts b/src/openApi/v3/parser/getMappedType.spec.ts index 7b40748a..8821b440 100644 --- a/src/openApi/v3/parser/getMappedType.spec.ts +++ b/src/openApi/v3/parser/getMappedType.spec.ts @@ -2,8 +2,8 @@ import { getMappedType } from './getMappedType'; describe('getMappedType', () => { it('should map types to the basics', () => { - expect(getMappedType('File')).toEqual('File'); - expect(getMappedType('file')).toEqual('File'); + expect(getMappedType('File')).toEqual('binary'); + expect(getMappedType('file')).toEqual('binary'); expect(getMappedType('string')).toEqual('string'); expect(getMappedType('date')).toEqual('string'); expect(getMappedType('date-time')).toEqual('string'); diff --git a/src/openApi/v3/parser/getMappedType.ts b/src/openApi/v3/parser/getMappedType.ts index f0ccb3ee..a7322756 100644 --- a/src/openApi/v3/parser/getMappedType.ts +++ b/src/openApi/v3/parser/getMappedType.ts @@ -1,6 +1,6 @@ const TYPE_MAPPINGS = new Map([ - ['File', 'File'], - ['file', 'File'], + ['File', 'binary'], + ['file', 'binary'], ['any', 'any'], ['object', 'any'], ['array', 'any[]'], @@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map([ */ export function getMappedType(type: string, format?: string): string | undefined { if (format === 'binary') { - return 'File'; + return 'binary'; } return TYPE_MAPPINGS.get(type); } diff --git a/src/templates/partials/base.hbs b/src/templates/partials/base.hbs index 343cbca9..4b34ce85 100644 --- a/src/templates/partials/base.hbs +++ b/src/templates/partials/base.hbs @@ -1,4 +1,4 @@ -{{~#equals base 'File'~}} +{{~#equals base 'binary'~}} {{~#equals @root.httpClient 'fetch'}}Blob{{/equals~}} {{~#equals @root.httpClient 'xhr'}}Blob{{/equals~}} {{~#equals @root.httpClient 'axios'}}Blob{{/equals~}} diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index bc880639..beac91f8 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -1520,7 +1520,7 @@ export const $ModelWithArray = { propWithFile: { type: 'array', contains: { - type: 'File', + type: 'binary', }, }, propWithNumber: { @@ -1886,7 +1886,7 @@ exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleFile.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { - type: 'File', + type: 'binary', };" `; @@ -4416,7 +4416,7 @@ export const $ModelWithArray = { propWithFile: { type: 'array', contains: { - type: 'File', + type: 'binary', }, }, propWithNumber: { @@ -4799,7 +4799,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleFile.ts 1`] = ` /* tslint:disable */ /* eslint-disable */ export const $SimpleFile = { - type: 'File', + type: 'binary', };" `; diff --git a/yarn.lock b/yarn.lock index 2555410c..f3559f82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1363,11 +1363,6 @@ jest-diff "^27.0.0" pretty-format "^27.0.0" -"@types/js-yaml@4.0.4": - version "4.0.4" - resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.4.tgz#cc38781257612581a1a0eb25f1709d2b06812fce" - integrity sha512-AuHubXUmg0AzkXH0Mx6sIxeY/1C110mm/EkE/gB1sTRz3h2dao2W/63q42SlVST+lICxz5Oki2hzYA6+KnnieQ== - "@types/json-schema@^7.0.6", "@types/json-schema@^7.0.9": version "7.0.9" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" @@ -3539,7 +3534,7 @@ js-yaml@3.14.1, js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@4.1.0, js-yaml@^4.1.0: +js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==