codegen-openapi-ts 0.8.0-alpha.9 → 0.9.0-alpha.3
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 +1 -1
- package/README.md +56 -205
- package/bin/index.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +74 -55
- package/types/index.d.ts +41 -0
- package/bin/cli.js +0 -27
- package/dist/index.d.ts +0 -79
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codegen-openapi-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-alpha.3",
|
|
4
4
|
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
|
5
5
|
"author": "devteaa",
|
|
6
6
|
"homepage": "https://github.com/devteaa/codegen-openapi-ts",
|
|
@@ -24,89 +24,108 @@
|
|
|
24
24
|
],
|
|
25
25
|
"maintainers": [
|
|
26
26
|
{
|
|
27
|
-
"name": "
|
|
28
|
-
"email": "
|
|
27
|
+
"name": "Ferdi Koomen",
|
|
28
|
+
"email": "info@madebyferdi.com"
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"main": "dist/index.js",
|
|
32
|
-
"types": "
|
|
32
|
+
"types": "types/index.d.ts",
|
|
33
33
|
"bin": {
|
|
34
|
-
"
|
|
35
|
-
"codegen-openapi-ts-cli": "bin/cli.js"
|
|
34
|
+
"openapi": "bin/index.js"
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
37
|
"bin/index.js",
|
|
39
38
|
"dist/index.js",
|
|
40
|
-
"
|
|
39
|
+
"types/index.d.ts"
|
|
41
40
|
],
|
|
42
41
|
"scripts": {
|
|
43
42
|
"clean": "rimraf ./dist ./test/generated ./test/e2e/generated ./samples/generated ./coverage ./node_modules/.cache",
|
|
44
43
|
"build": "rollup --config --environment NODE_ENV:development",
|
|
45
44
|
"build:watch": "rollup --config --environment NODE_ENV:development --watch",
|
|
46
45
|
"release": "rollup --config --environment NODE_ENV:production",
|
|
47
|
-
"
|
|
46
|
+
"validate": "tsc --project tsconfig.json --noEmit",
|
|
47
|
+
"run": "node ./test/index.js",
|
|
48
48
|
"test": "jest --selectProjects UNIT",
|
|
49
49
|
"test:update": "jest --selectProjects UNIT --updateSnapshot",
|
|
50
50
|
"test:watch": "jest --selectProjects UNIT --watch",
|
|
51
51
|
"test:coverage": "jest --selectProjects UNIT --coverage",
|
|
52
|
-
"test:e2e": "jest --selectProjects E2E --runInBand",
|
|
53
|
-
"eslint": "eslint
|
|
54
|
-
"eslint:fix": "eslint
|
|
55
|
-
"
|
|
56
|
-
"prettier:fix": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --write",
|
|
57
|
-
"prepublishOnly": "yarn run clean && yarn run release",
|
|
52
|
+
"test:e2e": "jest --selectProjects E2E --runInBand --verbose",
|
|
53
|
+
"eslint": "eslint .",
|
|
54
|
+
"eslint:fix": "eslint . --fix",
|
|
55
|
+
"prepare": "npm run clean && npm run release",
|
|
58
56
|
"codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b",
|
|
57
|
+
"docker": "docker build -t eeelenbaas/openapi-typescript-codegen .",
|
|
59
58
|
"deploy-dry": "npm publish --dry-run",
|
|
60
59
|
"deploy-prod": "npm publish && npm version patch",
|
|
61
60
|
"deploy-prerelease": "npm version prerelease && npm publish"
|
|
62
61
|
},
|
|
63
62
|
"dependencies": {
|
|
64
|
-
"@
|
|
65
|
-
"abort-controller": "^3.0.0",
|
|
63
|
+
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
66
64
|
"api-spec-converter": "^2.12.0",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"commander": "^8.3.0",
|
|
70
|
-
"cross-blob": "^2.0.1",
|
|
65
|
+
"camelcase": "^6.3.0",
|
|
66
|
+
"commander": "^11.1.0",
|
|
71
67
|
"esm-config": "^1.1.0",
|
|
72
|
-
"
|
|
73
|
-
"handlebars": "^4.7.
|
|
74
|
-
"json-schema-ref-parser": "^9.0.7",
|
|
75
|
-
"mkdirp": "^1.0.4",
|
|
76
|
-
"node-fetch": "^2.6.5",
|
|
77
|
-
"rimraf": "^3.0.2",
|
|
68
|
+
"fs-extra": "^11.2.0",
|
|
69
|
+
"handlebars": "^4.7.8",
|
|
78
70
|
"shelljs": "^0.8.5"
|
|
79
71
|
},
|
|
80
72
|
"devDependencies": {
|
|
81
|
-
"@
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
87
|
-
"@
|
|
88
|
-
"@
|
|
89
|
-
"@
|
|
90
|
-
"@
|
|
91
|
-
"@
|
|
92
|
-
"@
|
|
93
|
-
"@
|
|
73
|
+
"@angular-devkit/build-angular": "17.0.9",
|
|
74
|
+
"@angular/animations": "17.0.8",
|
|
75
|
+
"@angular/cli": "17.0.9",
|
|
76
|
+
"@angular/common": "17.0.8",
|
|
77
|
+
"@angular/compiler": "17.0.8",
|
|
78
|
+
"@angular/compiler-cli": "17.0.8",
|
|
79
|
+
"@angular/core": "17.0.8",
|
|
80
|
+
"@angular/forms": "17.0.8",
|
|
81
|
+
"@angular/platform-browser": "17.0.8",
|
|
82
|
+
"@angular/platform-browser-dynamic": "17.0.8",
|
|
83
|
+
"@angular/router": "17.0.8",
|
|
84
|
+
"@babel/cli": "7.23.9",
|
|
85
|
+
"@babel/core": "7.23.9",
|
|
86
|
+
"@babel/preset-env": "7.23.9",
|
|
87
|
+
"@babel/preset-typescript": "7.23.3",
|
|
88
|
+
"@rollup/plugin-commonjs": "25.0.7",
|
|
89
|
+
"@rollup/plugin-node-resolve": "15.2.3",
|
|
90
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
91
|
+
"@rollup/plugin-typescript": "11.1.6",
|
|
92
|
+
"@types/cross-spawn": "6.0.6",
|
|
93
|
+
"@types/express": "4.17.21",
|
|
94
|
+
"@types/fs-extra": "^11.0.4",
|
|
95
|
+
"@types/glob": "8.1.0",
|
|
96
|
+
"@types/jest": "29.5.11",
|
|
97
|
+
"@types/node": "20.11.11",
|
|
98
|
+
"@types/node-fetch": "2.6.10",
|
|
99
|
+
"@types/qs": "6.9.11",
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "6.20.0",
|
|
101
|
+
"@typescript-eslint/parser": "6.20.0",
|
|
102
|
+
"abort-controller": "3.0.0",
|
|
103
|
+
"axios": "1.6.7",
|
|
94
104
|
"codecov": "3.8.3",
|
|
95
|
-
"
|
|
96
|
-
"eslint
|
|
97
|
-
"eslint-
|
|
98
|
-
"eslint-plugin-
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
105
|
+
"cross-spawn": "7.0.3",
|
|
106
|
+
"eslint": "8.56.0",
|
|
107
|
+
"eslint-config-prettier": "9.1.0",
|
|
108
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
109
|
+
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
110
|
+
"express": "4.18.2",
|
|
111
|
+
"form-data": "4.0.0",
|
|
112
|
+
"glob": "10.3.10",
|
|
113
|
+
"jest": "29.7.0",
|
|
114
|
+
"jest-cli": "29.7.0",
|
|
115
|
+
"node-fetch": "2.7.0",
|
|
116
|
+
"prettier": "3.2.4",
|
|
117
|
+
"puppeteer": "21.10.0",
|
|
118
|
+
"qs": "6.11.2",
|
|
119
|
+
"rimraf": "5.0.5",
|
|
120
|
+
"rollup": "4.7.0",
|
|
121
|
+
"rxjs": "7.8.1",
|
|
122
|
+
"ts-node": "10.9.2",
|
|
123
|
+
"tslib": "2.6.2",
|
|
124
|
+
"typescript": "5.2.2",
|
|
125
|
+
"zone.js": "0.14.3"
|
|
126
|
+
},
|
|
127
|
+
"overrides": {
|
|
128
|
+
"node-fetch": "2.7.0",
|
|
129
|
+
"rollup": "4.7.0"
|
|
111
130
|
}
|
|
112
131
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare enum HttpClient {
|
|
2
|
+
FETCH = 'fetch',
|
|
3
|
+
XHR = 'xhr',
|
|
4
|
+
NODE = 'node',
|
|
5
|
+
AXIOS = 'axios',
|
|
6
|
+
ANGULAR = 'angular',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare enum Indent {
|
|
10
|
+
SPACE_4 = '4',
|
|
11
|
+
SPACE_2 = '2',
|
|
12
|
+
TAB = 'tab',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Options = {
|
|
16
|
+
input: string | Record<string, any>;
|
|
17
|
+
output: string;
|
|
18
|
+
httpClient?: HttpClient | 'fetch' | 'xhr' | 'node' | 'axios' | 'angular';
|
|
19
|
+
clientName?: string;
|
|
20
|
+
useOptions?: boolean;
|
|
21
|
+
useUnionTypes?: boolean;
|
|
22
|
+
exportCore?: boolean;
|
|
23
|
+
exportServices?: boolean;
|
|
24
|
+
exportModels?: boolean;
|
|
25
|
+
exportSchemas?: boolean;
|
|
26
|
+
indent?: Indent | '4' | '2' | 'tab';
|
|
27
|
+
postfixServices?: string;
|
|
28
|
+
postfixModels?: string;
|
|
29
|
+
request?: string;
|
|
30
|
+
write?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export declare function generate(options: Options): Promise<void>;
|
|
34
|
+
|
|
35
|
+
declare type OpenAPI = {
|
|
36
|
+
HttpClient: HttpClient;
|
|
37
|
+
Indent: Indent;
|
|
38
|
+
generate: typeof generate;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default OpenAPI;
|
package/bin/cli.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const program = require('commander');
|
|
7
|
-
const pkg = require('../package.json');
|
|
8
|
-
|
|
9
|
-
const params = program
|
|
10
|
-
.name('codegen-openapi-ts-cli')
|
|
11
|
-
.usage('[options]')
|
|
12
|
-
.version(pkg.version)
|
|
13
|
-
.argument('<source>', 'Swagger/OpenAPI response url')
|
|
14
|
-
.argument('<output>', 'Output folder name')
|
|
15
|
-
.parse(process.argv)
|
|
16
|
-
.processedArgs;
|
|
17
|
-
|
|
18
|
-
const OpenAPI = require(path.resolve(__dirname, '../dist/index.js'));
|
|
19
|
-
|
|
20
|
-
if (OpenAPI) {
|
|
21
|
-
OpenAPI.generate({
|
|
22
|
-
input: params[0],
|
|
23
|
-
output: params[1],
|
|
24
|
-
useOptions: true,
|
|
25
|
-
useUnionTypes: true
|
|
26
|
-
})
|
|
27
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { ConverterInput } from 'api-spec-converter';
|
|
2
|
-
import { HttpClient } from './HttpClient';
|
|
3
|
-
export { HttpClient } from './HttpClient';
|
|
4
|
-
export declare type Options = {
|
|
5
|
-
input: string | Record<string, any>;
|
|
6
|
-
output: string;
|
|
7
|
-
httpClient?: HttpClient;
|
|
8
|
-
useOptions?: boolean;
|
|
9
|
-
useUnionTypes?: boolean;
|
|
10
|
-
exportCore?: boolean;
|
|
11
|
-
exportServices?: boolean;
|
|
12
|
-
exportModels?: boolean;
|
|
13
|
-
exportSchemas?: boolean;
|
|
14
|
-
postfix?: string;
|
|
15
|
-
request?: string;
|
|
16
|
-
write?: boolean;
|
|
17
|
-
selectedOnly?: boolean;
|
|
18
|
-
appendTemplate?: ReturnType<typeof defineConfig>['appendTemplate'];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Generate the OpenAPI client. This method will read the OpenAPI specification and based on the
|
|
22
|
-
* given language it will generate the client, including the typed models, validation schemas,
|
|
23
|
-
* service layer, etc.
|
|
24
|
-
* @param input The relative location of the OpenAPI spec
|
|
25
|
-
* @param output The relative location of the output directory
|
|
26
|
-
* @param httpClient The selected httpClient (fetch, xhr, node or axios)
|
|
27
|
-
* @param useUnionTypes Use union types instead of enums
|
|
28
|
-
* @param exportCore: Generate core client classes
|
|
29
|
-
* @param exportServices: Generate services
|
|
30
|
-
* @param exportModels: Generate models
|
|
31
|
-
* @param exportSchemas: Generate schemas
|
|
32
|
-
* @param postfix: Service name postfix
|
|
33
|
-
* @param request: Path to custom request file
|
|
34
|
-
* @param write Write the files to disk (true or false)
|
|
35
|
-
*/
|
|
36
|
-
export declare function generate({ input, output, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, postfix, request, write, selectedOnly, appendTemplate }: Options): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Generate the OpenAPI client with options to convert swagger to openapi etc.
|
|
39
|
-
* @param converterInput.from The schema specification for the response (swagger_1, swagger_2, openapi_3)
|
|
40
|
-
* @param converterInput.to The schema specification for the output (openapi_3)
|
|
41
|
-
* @param converterInput.source The relative location of the OpenAPI spec
|
|
42
|
-
* @param options.httpClient The selected httpClient (fetch, xhr, node or axios)
|
|
43
|
-
* @param options.useUnionTypes Use union types instead of enums
|
|
44
|
-
* @param options.exportCore: Generate core client classes
|
|
45
|
-
* @param options.exportServices: Generate services
|
|
46
|
-
* @param options.exportModels: Generate models
|
|
47
|
-
* @param options.exportSchemas: Generate schemas
|
|
48
|
-
* @param options.postfix: Service name postfix
|
|
49
|
-
* @param options.request: Path to custom request file
|
|
50
|
-
* @param options.write Write the files to disk (true or false)
|
|
51
|
-
*/
|
|
52
|
-
export declare function convertAndGenerate({ from, source }: ConverterInput, { input, output, useOptions, useUnionTypes }: Options, urlMethodMapping?: ServiceConfigWithMappings['urlMethodMapping'], selectedOnly?: ServiceConfigWithMappings['selectedOnly'], modelNameMapping?: BaseServiceConfig['modelNameMapping'], appendTemplate?: ReturnType<typeof defineConfig>['appendTemplate'], proxyConfig?: BaseServiceConfig['proxyConfig']): Promise<void>;
|
|
53
|
-
export declare type BaseServiceConfig = {
|
|
54
|
-
source: string;
|
|
55
|
-
from: 'swagger_1' | 'swagger_2' | 'openapi_3' | 'api_blueprint' | 'io_docs' | 'google' | 'raml' | 'wadl';
|
|
56
|
-
output: string;
|
|
57
|
-
proxyConfig?: (path: string) => string;
|
|
58
|
-
modelNameMapping?: (path: string) => string;
|
|
59
|
-
};
|
|
60
|
-
export declare type ServiceConfigDefault = BaseServiceConfig & {
|
|
61
|
-
urlMethodMapping: undefined;
|
|
62
|
-
selectedOnly: undefined;
|
|
63
|
-
};
|
|
64
|
-
export declare type ServiceConfigWithMappings = BaseServiceConfig & {
|
|
65
|
-
urlMethodMapping: {
|
|
66
|
-
originalUrl: string;
|
|
67
|
-
method: 'get' | 'post' | 'put' | 'delete';
|
|
68
|
-
methodName: string;
|
|
69
|
-
proxyUrl?: string;
|
|
70
|
-
}[];
|
|
71
|
-
selectedOnly: boolean;
|
|
72
|
-
};
|
|
73
|
-
export declare function defineConfig(config: {
|
|
74
|
-
appendTemplate?: string;
|
|
75
|
-
services: (ServiceConfigDefault | ServiceConfigWithMappings)[];
|
|
76
|
-
}): {
|
|
77
|
-
appendTemplate?: string | undefined;
|
|
78
|
-
services: (ServiceConfigDefault | ServiceConfigWithMappings)[];
|
|
79
|
-
};
|