Skip to content

Commit 21c92ee

Browse files
committed
Merge branch 'master' into pr/419
# Conflicts: # src/openApi/v3/parser/getModel.ts
2 parents f6e425b + 2d8aa16 commit 21c92ee

File tree

79 files changed

+1013
-801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1013
-801
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"@typescript-eslint/explicit-module-boundary-types": 0,
2525
"sort-imports": "off",
2626
"import/order": "off",
27-
"simple-import-sort/sort": "error",
27+
"simple-import-sort/imports": "error",
28+
"simple-import-sort/exports": "error",
2829
"prettier/prettier": ["error"]
2930
}
3031
}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,16 @@ npm install node-fetch --save-dev
441441
npm install form-data --save-dev
442442
```
443443

444+
In order to compile the project and resolve the imports, you will need to enable the `allowSyntheticDefaultImports`
445+
in your `tsconfig.json` file.
446+
447+
```json
448+
{
449+
"allowSyntheticDefaultImports": true
450+
}
451+
```
452+
453+
444454
[npm-url]: https://npmjs.org/package/openapi-typescript-codegen
445455
[npm-image]: https://img.shields.io/npm/v/openapi-typescript-codegen.svg
446456
[license-url]: LICENSE

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-typescript-codegen",
3-
"version": "0.5.4",
3+
"version": "0.6.0",
44
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
@@ -77,18 +77,18 @@
7777
"@babel/preset-typescript": "7.12.1",
7878
"@rollup/plugin-commonjs": "16.0.0",
7979
"@rollup/plugin-node-resolve": "10.0.0",
80-
"@types/express": "4.17.8",
80+
"@types/express": "4.17.9",
8181
"@types/jest": "26.0.15",
8282
"@types/js-yaml": "3.12.5",
83-
"@types/node": "14.14.6",
83+
"@types/node": "14.14.7",
8484
"@types/node-fetch": "2.5.7",
85-
"@typescript-eslint/eslint-plugin": "4.6.1",
86-
"@typescript-eslint/parser": "4.6.1",
85+
"@typescript-eslint/eslint-plugin": "4.7.0",
86+
"@typescript-eslint/parser": "4.7.0",
8787
"codecov": "3.8.1",
8888
"eslint": "7.13.0",
8989
"eslint-config-prettier": "6.15.0",
9090
"eslint-plugin-prettier": "3.1.4",
91-
"eslint-plugin-simple-import-sort": "5.0.3",
91+
"eslint-plugin-simple-import-sort": "6.0.0",
9292
"express": "4.17.1",
9393
"form-data": "3.0.0",
9494
"glob": "7.1.6",
@@ -97,7 +97,7 @@
9797
"node-fetch": "2.6.1",
9898
"prettier": "2.1.2",
9999
"puppeteer": "5.4.1",
100-
"rollup": "2.33.1",
100+
"rollup": "2.33.2",
101101
"rollup-plugin-terser": "7.0.2",
102102
"rollup-plugin-typescript2": "0.29.0",
103103
"typescript": "4.0.5"

src/client/interfaces/Model.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,4 @@ export interface Model extends Schema {
1515
enum: Enum[];
1616
enums: Model[];
1717
properties: Model[];
18-
extendedFrom?: string[];
19-
extendedBy?: string[];
2018
}

src/openApi/v2/interfaces/OpenApiParameter.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { WithEnumExtension } from './Extensions/WithEnumExtension';
2-
import { WithNullableExtension } from './Extensions/WithNullableExtension';
2+
import type { WithNullableExtension } from './Extensions/WithNullableExtension';
33
import type { OpenApiItems } from './OpenApiItems';
44
import type { OpenApiReference } from './OpenApiReference';
55
import type { OpenApiSchema } from './OpenApiSchema';

src/openApi/v2/parser/constants.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/openApi/v2/parser/extendEnum.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export function extendEnum(enumerators: Enum[], definition: WithEnumExtension):
1212
const descriptions = definition['x-enum-descriptions'];
1313

1414
return enumerators.map((enumerator, index) => ({
15-
name: (names && names[index]) || enumerator.name,
16-
description: (descriptions && descriptions[index]) || enumerator.description,
15+
name: names?.[index] || enumerator.name,
16+
description: descriptions?.[index] || enumerator.description,
1717
value: enumerator.value,
1818
type: enumerator.type,
1919
}));

src/openApi/v2/parser/getEnum.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Enum } from '../../../client/interfaces/Enum';
2-
import { PrimaryType } from './constants';
32
import { isDefined } from './isDefined';
43

54
export function getEnum(values?: (string | number)[]): Enum[] {
@@ -14,7 +13,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
1413
return {
1514
name: `_${value}`,
1615
value: String(value),
17-
type: PrimaryType.NUMBER,
16+
type: 'number',
1817
description: null,
1918
};
2019
}
@@ -25,7 +24,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
2524
.replace(/([a-z])([A-Z]+)/g, '$1_$2')
2625
.toUpperCase(),
2726
value: `'${value}'`,
28-
type: PrimaryType.STRING,
27+
type: 'string',
2928
description: null,
3029
};
3130
});

src/openApi/v2/parser/getEnumFromDescription.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Enum } from '../../../client/interfaces/Enum';
2-
import { PrimaryType } from './constants';
32

43
export function getEnumFromDescription(description: string): Enum[] {
54
// Check if we can find this special format string:
@@ -20,7 +19,7 @@ export function getEnumFromDescription(description: string): Enum[] {
2019
.replace(/([a-z])([A-Z]+)/g, '$1_$2')
2120
.toUpperCase(),
2221
value: String(value),
23-
type: PrimaryType.NUMBER,
22+
type: 'number',
2423
description: null,
2524
});
2625
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { getMappedType } from './getMappedType';
33
describe('getMappedType', () => {
44
it('should map types to the basics', () => {
55
expect(getMappedType('File')).toEqual('File');
6-
expect(getMappedType('String')).toEqual('string');
6+
expect(getMappedType('file')).toEqual('File');
7+
expect(getMappedType('string')).toEqual('string');
78
expect(getMappedType('date')).toEqual('string');
89
expect(getMappedType('date-time')).toEqual('string');
910
expect(getMappedType('float')).toEqual('number');

0 commit comments

Comments
 (0)