Fixed issue #782

This commit is contained in:
Ferdi Koomen 2021-10-29 13:49:15 +02:00
parent 35bda10d18
commit ba0b79daac
7 changed files with 16 additions and 21 deletions

View File

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

View File

@ -1,6 +1,6 @@
const TYPE_MAPPINGS = new Map<string, string>([
['File', 'File'],
['file', 'File'],
['File', 'binary'],
['file', 'binary'],
['any', 'any'],
['object', 'any'],
['array', 'any[]'],
@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map<string, string>([
*/
export function getMappedType(type: string, format?: string): string | undefined {
if (format === 'binary') {
return 'File';
return 'binary';
}
return TYPE_MAPPINGS.get(type);
}

View File

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

View File

@ -1,6 +1,6 @@
const TYPE_MAPPINGS = new Map<string, string>([
['File', 'File'],
['file', 'File'],
['File', 'binary'],
['file', 'binary'],
['any', 'any'],
['object', 'any'],
['array', 'any[]'],
@ -27,7 +27,7 @@ const TYPE_MAPPINGS = new Map<string, string>([
*/
export function getMappedType(type: string, format?: string): string | undefined {
if (format === 'binary') {
return 'File';
return 'binary';
}
return TYPE_MAPPINGS.get(type);
}

View File

@ -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~}}

View File

@ -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',
};"
`;

View File

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