codegen-openapi-ts 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +216 -274
- package/bin/cli.js +35 -35
- package/bin/index.js +49 -49
- package/dist/index.d.ts +72 -0
- package/dist/index.js +1 -1
- package/package.json +113 -112
- package/types/helper.d.ts +58 -58
- package/types/index.d.ts +22 -22
package/package.json
CHANGED
|
@@ -1,112 +1,113 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "codegen-openapi-ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
|
5
|
-
"author": "devteaa",
|
|
6
|
-
"homepage": "https://github.com/devteaa/codegen-openapi-ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/devteaa/codegen-openapi-ts.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/devteaa/codegen-openapi/issues"
|
|
13
|
-
},
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"openapi",
|
|
17
|
-
"swagger",
|
|
18
|
-
"codegen",
|
|
19
|
-
"generator",
|
|
20
|
-
"typescript",
|
|
21
|
-
"yaml",
|
|
22
|
-
"json",
|
|
23
|
-
"node"
|
|
24
|
-
],
|
|
25
|
-
"maintainers": [
|
|
26
|
-
{
|
|
27
|
-
"name": "devteaa",
|
|
28
|
-
"email": "devtea@protonmail.com"
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"main": "dist/index.js",
|
|
32
|
-
"types": "
|
|
33
|
-
"bin": {
|
|
34
|
-
"codegen-openapi-ts": "bin/index.js",
|
|
35
|
-
"codegen-openapi-ts-cli": "bin/cli.js"
|
|
36
|
-
},
|
|
37
|
-
"files": [
|
|
38
|
-
"bin/index.js",
|
|
39
|
-
"dist/index.js",
|
|
40
|
-
"
|
|
41
|
-
"types/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"build
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"test
|
|
51
|
-
"test:
|
|
52
|
-
"test:
|
|
53
|
-
"test:
|
|
54
|
-
"
|
|
55
|
-
"eslint
|
|
56
|
-
"
|
|
57
|
-
"prettier
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"deploy-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"@babel/
|
|
83
|
-
"@babel/
|
|
84
|
-
"@babel/preset-
|
|
85
|
-
"@
|
|
86
|
-
"@rollup/plugin-
|
|
87
|
-
"@
|
|
88
|
-
"@types/
|
|
89
|
-
"@types/
|
|
90
|
-
"@types/
|
|
91
|
-
"@types/
|
|
92
|
-
"@
|
|
93
|
-
"@typescript-eslint/
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"eslint
|
|
97
|
-
"eslint-
|
|
98
|
-
"eslint-plugin-
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"jest
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"rollup
|
|
108
|
-
"rollup-plugin-
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "codegen-openapi-ts",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
|
5
|
+
"author": "devteaa",
|
|
6
|
+
"homepage": "https://github.com/devteaa/codegen-openapi-ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/devteaa/codegen-openapi-ts.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/devteaa/codegen-openapi/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"openapi",
|
|
17
|
+
"swagger",
|
|
18
|
+
"codegen",
|
|
19
|
+
"generator",
|
|
20
|
+
"typescript",
|
|
21
|
+
"yaml",
|
|
22
|
+
"json",
|
|
23
|
+
"node"
|
|
24
|
+
],
|
|
25
|
+
"maintainers": [
|
|
26
|
+
{
|
|
27
|
+
"name": "devteaa",
|
|
28
|
+
"email": "devtea@protonmail.com"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"main": "dist/index.js",
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
33
|
+
"bin": {
|
|
34
|
+
"codegen-openapi-ts": "bin/index.js",
|
|
35
|
+
"codegen-openapi-ts-cli": "bin/cli.js"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"bin/index.js",
|
|
39
|
+
"dist/index.js",
|
|
40
|
+
"dist/index.d.ts",
|
|
41
|
+
"types/index.d.ts",
|
|
42
|
+
"types/helper.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clean": "rimraf ./dist ./test/generated ./test/e2e/generated ./samples/generated ./coverage ./node_modules/.cache",
|
|
46
|
+
"build": "rollup --config --environment NODE_ENV:development",
|
|
47
|
+
"build:watch": "rollup --config --environment NODE_ENV:development --watch",
|
|
48
|
+
"release": "rollup --config --environment NODE_ENV:production",
|
|
49
|
+
"run": "NODE_ENV=production node ./test/index.js",
|
|
50
|
+
"test": "jest --selectProjects UNIT",
|
|
51
|
+
"test:update": "jest --selectProjects UNIT --updateSnapshot",
|
|
52
|
+
"test:watch": "jest --selectProjects UNIT --watch",
|
|
53
|
+
"test:coverage": "jest --selectProjects UNIT --coverage",
|
|
54
|
+
"test:e2e": "jest --selectProjects E2E --runInBand",
|
|
55
|
+
"eslint": "eslint \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\"",
|
|
56
|
+
"eslint:fix": "eslint \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --fix",
|
|
57
|
+
"prettier": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --check",
|
|
58
|
+
"prettier:fix": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --write",
|
|
59
|
+
"prepublishOnly": "yarn run clean && yarn run release",
|
|
60
|
+
"codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b",
|
|
61
|
+
"deploy-dry": "npm publish --dry-run",
|
|
62
|
+
"deploy-prod": "npm publish && npm version patch"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@types/node-fetch": "^2.5.12",
|
|
66
|
+
"abort-controller": "^3.0.0",
|
|
67
|
+
"api-spec-converter": "^2.12.0",
|
|
68
|
+
"axios": "^0.24.0",
|
|
69
|
+
"camelcase": "^6.2.1",
|
|
70
|
+
"commander": "^8.3.0",
|
|
71
|
+
"cross-blob": "^2.0.1",
|
|
72
|
+
"esm-config": "^1.1.0",
|
|
73
|
+
"form-data": "^4.0.0",
|
|
74
|
+
"handlebars": "^4.7.6",
|
|
75
|
+
"json-schema-ref-parser": "^9.0.7",
|
|
76
|
+
"mkdirp": "^1.0.4",
|
|
77
|
+
"node-fetch": "^2.6.5",
|
|
78
|
+
"rimraf": "^3.0.2",
|
|
79
|
+
"shelljs": "^0.8.5"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@babel/cli": "7.16.0",
|
|
83
|
+
"@babel/core": "7.16.0",
|
|
84
|
+
"@babel/preset-env": "7.16.4",
|
|
85
|
+
"@babel/preset-typescript": "7.16.0",
|
|
86
|
+
"@rollup/plugin-commonjs": "21.0.1",
|
|
87
|
+
"@rollup/plugin-node-resolve": "13.0.6",
|
|
88
|
+
"@types/express": "4.17.13",
|
|
89
|
+
"@types/glob": "7.2.0",
|
|
90
|
+
"@types/jest": "^27.0.3",
|
|
91
|
+
"@types/node": "16.11.11",
|
|
92
|
+
"@types/qs": "6.9.7",
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "5.5.0",
|
|
94
|
+
"@typescript-eslint/parser": "5.5.0",
|
|
95
|
+
"codecov": "3.8.3",
|
|
96
|
+
"eslint": "8.3.0",
|
|
97
|
+
"eslint-config-prettier": "8.3.0",
|
|
98
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
99
|
+
"eslint-plugin-simple-import-sort": "7.0.0",
|
|
100
|
+
"express": "4.17.1",
|
|
101
|
+
"glob": "7.2.0",
|
|
102
|
+
"jest": "27.4.3",
|
|
103
|
+
"jest-cli": "27.4.3",
|
|
104
|
+
"prettier": "2.8.4",
|
|
105
|
+
"puppeteer": "12.0.1",
|
|
106
|
+
"qs": "6.10.1",
|
|
107
|
+
"rollup": "2.60.2",
|
|
108
|
+
"rollup-plugin-terser": "7.0.2",
|
|
109
|
+
"rollup-plugin-typescript2": "0.31.1",
|
|
110
|
+
"tslib": "2.3.1",
|
|
111
|
+
"typescript": "4.5.2"
|
|
112
|
+
}
|
|
113
|
+
}
|
package/types/helper.d.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
type NonObjectKeysOf<T> = {
|
|
2
|
-
[K in keyof T]: T[K] extends Array<any> ? K : T[K] extends object ? never : K
|
|
3
|
-
}[keyof T];
|
|
4
|
-
|
|
5
|
-
type ValuesOf<T> = T[keyof T];
|
|
6
|
-
type ObjectValuesOf<T extends Object> = Exclude<
|
|
7
|
-
Exclude<Extract<ValuesOf<T>, object>, never>,
|
|
8
|
-
Array<any>
|
|
9
|
-
>;
|
|
10
|
-
|
|
11
|
-
type UnionToIntersection<U> = (U extends any
|
|
12
|
-
? (k: U) => void
|
|
13
|
-
: never) extends ((k: infer I) => void)
|
|
14
|
-
? I
|
|
15
|
-
: never;
|
|
16
|
-
|
|
17
|
-
export type DeepFlatten<T> = T extends any
|
|
18
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
19
|
-
UnionToIntersection<DeepFlatten2<ObjectValuesOf<T>>>
|
|
20
|
-
: never;
|
|
21
|
-
|
|
22
|
-
type DeepFlatten2<T> = T extends any
|
|
23
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
24
|
-
UnionToIntersection<DeepFlatten3<ObjectValuesOf<T>>>
|
|
25
|
-
: never;
|
|
26
|
-
|
|
27
|
-
type DeepFlatten3<T> = T extends any
|
|
28
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
29
|
-
UnionToIntersection<DeepFlatten4<ObjectValuesOf<T>>>
|
|
30
|
-
: never;
|
|
31
|
-
|
|
32
|
-
type DeepFlatten4<T> = T extends any
|
|
33
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
34
|
-
UnionToIntersection<DeepFlatten5<ObjectValuesOf<T>>>
|
|
35
|
-
: never;
|
|
36
|
-
|
|
37
|
-
type DeepFlatten5<T> = T extends any
|
|
38
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
39
|
-
UnionToIntersection<DeepFlatten6<ObjectValuesOf<T>>>
|
|
40
|
-
: never;
|
|
41
|
-
|
|
42
|
-
type DeepFlatten6<T> = T extends any
|
|
43
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
44
|
-
UnionToIntersection<DeepFlatten7<ObjectValuesOf<T>>>
|
|
45
|
-
: never;
|
|
46
|
-
|
|
47
|
-
type DeepFlatten7<T> = T extends any
|
|
48
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
49
|
-
UnionToIntersection<DeepFlatten8<ObjectValuesOf<T>>>
|
|
50
|
-
: never;
|
|
51
|
-
|
|
52
|
-
type DeepFlatten8<T> = T extends any
|
|
53
|
-
? Pick<T, NonObjectKeysOf<T>> &
|
|
54
|
-
UnionToIntersection<DeepFlatten9<ObjectValuesOf<T>>>
|
|
55
|
-
: never;
|
|
56
|
-
|
|
57
|
-
type DeepFlatten9<T> = T extends any
|
|
58
|
-
? Pick<T, NonObjectKeysOf<T>>
|
|
1
|
+
type NonObjectKeysOf<T> = {
|
|
2
|
+
[K in keyof T]: T[K] extends Array<any> ? K : T[K] extends object ? never : K
|
|
3
|
+
}[keyof T];
|
|
4
|
+
|
|
5
|
+
type ValuesOf<T> = T[keyof T];
|
|
6
|
+
type ObjectValuesOf<T extends Object> = Exclude<
|
|
7
|
+
Exclude<Extract<ValuesOf<T>, object>, never>,
|
|
8
|
+
Array<any>
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
type UnionToIntersection<U> = (U extends any
|
|
12
|
+
? (k: U) => void
|
|
13
|
+
: never) extends ((k: infer I) => void)
|
|
14
|
+
? I
|
|
15
|
+
: never;
|
|
16
|
+
|
|
17
|
+
export type DeepFlatten<T> = T extends any
|
|
18
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
19
|
+
UnionToIntersection<DeepFlatten2<ObjectValuesOf<T>>>
|
|
20
|
+
: never;
|
|
21
|
+
|
|
22
|
+
type DeepFlatten2<T> = T extends any
|
|
23
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
24
|
+
UnionToIntersection<DeepFlatten3<ObjectValuesOf<T>>>
|
|
25
|
+
: never;
|
|
26
|
+
|
|
27
|
+
type DeepFlatten3<T> = T extends any
|
|
28
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
29
|
+
UnionToIntersection<DeepFlatten4<ObjectValuesOf<T>>>
|
|
30
|
+
: never;
|
|
31
|
+
|
|
32
|
+
type DeepFlatten4<T> = T extends any
|
|
33
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
34
|
+
UnionToIntersection<DeepFlatten5<ObjectValuesOf<T>>>
|
|
35
|
+
: never;
|
|
36
|
+
|
|
37
|
+
type DeepFlatten5<T> = T extends any
|
|
38
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
39
|
+
UnionToIntersection<DeepFlatten6<ObjectValuesOf<T>>>
|
|
40
|
+
: never;
|
|
41
|
+
|
|
42
|
+
type DeepFlatten6<T> = T extends any
|
|
43
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
44
|
+
UnionToIntersection<DeepFlatten7<ObjectValuesOf<T>>>
|
|
45
|
+
: never;
|
|
46
|
+
|
|
47
|
+
type DeepFlatten7<T> = T extends any
|
|
48
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
49
|
+
UnionToIntersection<DeepFlatten8<ObjectValuesOf<T>>>
|
|
50
|
+
: never;
|
|
51
|
+
|
|
52
|
+
type DeepFlatten8<T> = T extends any
|
|
53
|
+
? Pick<T, NonObjectKeysOf<T>> &
|
|
54
|
+
UnionToIntersection<DeepFlatten9<ObjectValuesOf<T>>>
|
|
55
|
+
: never;
|
|
56
|
+
|
|
57
|
+
type DeepFlatten9<T> = T extends any
|
|
58
|
+
? Pick<T, NonObjectKeysOf<T>>
|
|
59
59
|
: UnionToIntersection<ObjectValuesOf<T>>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export declare enum HttpClient {
|
|
2
|
-
FETCH = 'fetch',
|
|
3
|
-
XHR = 'xhr',
|
|
4
|
-
NODE = 'node',
|
|
5
|
-
AXIOS = 'axios',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type Options = {
|
|
9
|
-
input: string | Record<string, any>;
|
|
10
|
-
output: string;
|
|
11
|
-
httpClient?: HttpClient;
|
|
12
|
-
useOptions?: boolean;
|
|
13
|
-
useUnionTypes?: boolean;
|
|
14
|
-
exportCore?: boolean;
|
|
15
|
-
exportServices?: boolean;
|
|
16
|
-
exportModels?: boolean;
|
|
17
|
-
exportSchemas?: boolean;
|
|
18
|
-
request?: string;
|
|
19
|
-
write?: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export declare function generate(options: Options): Promise<void>;
|
|
1
|
+
export declare enum HttpClient {
|
|
2
|
+
FETCH = 'fetch',
|
|
3
|
+
XHR = 'xhr',
|
|
4
|
+
NODE = 'node',
|
|
5
|
+
AXIOS = 'axios',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Options = {
|
|
9
|
+
input: string | Record<string, any>;
|
|
10
|
+
output: string;
|
|
11
|
+
httpClient?: HttpClient;
|
|
12
|
+
useOptions?: boolean;
|
|
13
|
+
useUnionTypes?: boolean;
|
|
14
|
+
exportCore?: boolean;
|
|
15
|
+
exportServices?: boolean;
|
|
16
|
+
exportModels?: boolean;
|
|
17
|
+
exportSchemas?: boolean;
|
|
18
|
+
request?: string;
|
|
19
|
+
write?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export declare function generate(options: Options): Promise<void>;
|