Skip to content

Commit f84337a

Browse files
Merge branch 'master' into feature/generate-client-instance
2 parents 5bc3592 + 0eb5e91 commit f84337a

39 files changed

+1329
-598
lines changed

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-typescript-codegen",
3-
"version": "0.12.2",
3+
"version": "0.12.5",
44
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
@@ -63,7 +63,7 @@
6363
"@types/node-fetch": "^2.5.12",
6464
"abort-controller": "^3.0.0",
6565
"axios": "^0.24.0",
66-
"camelcase": "^6.2.0",
66+
"camelcase": "^6.2.1",
6767
"commander": "^8.3.0",
6868
"cross-blob": "^2.0.1",
6969
"form-data": "^4.0.0",
@@ -76,33 +76,33 @@
7676
"devDependencies": {
7777
"@babel/cli": "7.16.0",
7878
"@babel/core": "7.16.0",
79-
"@babel/preset-env": "7.16.0",
79+
"@babel/preset-env": "7.16.4",
8080
"@babel/preset-typescript": "7.16.0",
8181
"@rollup/plugin-commonjs": "21.0.1",
8282
"@rollup/plugin-node-resolve": "13.0.6",
8383
"@types/express": "4.17.13",
8484
"@types/glob": "7.2.0",
85-
"@types/jest": "27.0.2",
86-
"@types/node": "16.11.7",
85+
"@types/jest": "27.0.3",
86+
"@types/node": "16.11.11",
8787
"@types/qs": "6.9.7",
88-
"@typescript-eslint/eslint-plugin": "5.3.1",
89-
"@typescript-eslint/parser": "5.3.1",
88+
"@typescript-eslint/eslint-plugin": "5.5.0",
89+
"@typescript-eslint/parser": "5.5.0",
9090
"codecov": "3.8.3",
91-
"eslint": "8.2.0",
91+
"eslint": "8.3.0",
9292
"eslint-config-prettier": "8.3.0",
9393
"eslint-plugin-prettier": "4.0.0",
9494
"eslint-plugin-simple-import-sort": "7.0.0",
9595
"express": "4.17.1",
9696
"glob": "7.2.0",
97-
"jest": "27.3.1",
98-
"jest-cli": "27.3.1",
99-
"prettier": "2.4.1",
100-
"puppeteer": "11.0.0",
97+
"jest": "27.4.3",
98+
"jest-cli": "27.4.3",
99+
"prettier": "2.5.0",
100+
"puppeteer": "12.0.1",
101101
"qs": "6.10.1",
102-
"rollup": "2.59.0",
102+
"rollup": "2.60.2",
103103
"rollup-plugin-terser": "7.0.2",
104-
"rollup-plugin-typescript2": "0.30.0",
104+
"rollup-plugin-typescript2": "0.31.1",
105105
"tslib": "2.3.1",
106-
"typescript": "4.4.4"
106+
"typescript": "4.5.2"
107107
}
108108
}

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const handlebarsPlugin = () => ({
3838
union: true,
3939
intersection: true,
4040
enumerator: true,
41+
escapeQuotes: true,
4142
},
4243
});
4344
return `export default ${templateSpec};`;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getMappedType } from './getMappedType';
22

33
describe('getMappedType', () => {
44
it('should map types to the basics', () => {
5-
expect(getMappedType('File')).toEqual('binary');
65
expect(getMappedType('file')).toEqual('binary');
76
expect(getMappedType('string')).toEqual('string');
87
expect(getMappedType('date')).toEqual('string');

src/openApi/v2/parser/getMappedType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const TYPE_MAPPINGS = new Map<string, string>([
2-
['File', 'binary'],
32
['file', 'binary'],
43
['any', 'any'],
54
['object', 'any'],

src/openApi/v2/parser/getModelComposition.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export function getModelComposition(
5959
modelProperties.forEach(modelProperty => {
6060
composition.imports.push(...modelProperty.imports);
6161
composition.enums.push(...modelProperty.enums);
62+
if (modelProperty.export === 'enum') {
63+
composition.enums.push(modelProperty);
64+
}
6265
});
6366
properties.push(...modelProperties);
6467
}

src/openApi/v2/parser/getServer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export function getServer(openApi: OpenApi): string {
88
const scheme = openApi.schemes?.[0] || 'http';
99
const host = openApi.host;
1010
const basePath = openApi.basePath || '';
11-
return host ? `${scheme}://${host}${basePath}` : basePath;
11+
const url = host ? `${scheme}://${host}${basePath}` : basePath;
12+
return url.replace(/\/$/g, '');
1213
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getMappedType } from './getMappedType';
22

33
describe('getMappedType', () => {
44
it('should map types to the basics', () => {
5-
expect(getMappedType('File')).toEqual('binary');
65
expect(getMappedType('file')).toEqual('binary');
76
expect(getMappedType('string')).toEqual('string');
87
expect(getMappedType('date')).toEqual('string');

src/openApi/v3/parser/getMappedType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const TYPE_MAPPINGS = new Map<string, string>([
2-
['File', 'binary'],
32
['file', 'binary'],
43
['any', 'any'],
54
['object', 'any'],

src/openApi/v3/parser/getModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function getModel(
165165
model.default = getModelDefault(definition, model);
166166

167167
if (definition.properties) {
168-
const modelProperties = getModelProperties(openApi, definition, getModel);
168+
const modelProperties = getModelProperties(openApi, definition, getModel, model);
169169
modelProperties.forEach(modelProperty => {
170170
model.imports.push(...modelProperty.imports);
171171
model.enums.push(...modelProperty.enums);
@@ -185,7 +185,7 @@ export function getModel(
185185
model.type = definitionType.type;
186186
model.base = definitionType.base;
187187
model.template = definitionType.template;
188-
model.isNullable = definitionType.isNullable;
188+
model.isNullable = definitionType.isNullable || model.isNullable;
189189
model.imports.push(...definitionType.imports);
190190
model.default = getModelDefault(definition, model);
191191
return model;

src/openApi/v3/parser/getModelComposition.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export function getModelComposition(
5959
modelProperties.forEach(modelProperty => {
6060
composition.imports.push(...modelProperty.imports);
6161
composition.enums.push(...modelProperty.enums);
62+
if (modelProperty.export === 'enum') {
63+
composition.enums.push(modelProperty);
64+
}
6265
});
6366
properties.push(...modelProperties);
6467
}

0 commit comments

Comments
 (0)