@spec2ts/openapi-client 2.0.0-alpha.1 → 2.0.0-beta.10
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/CHANGELOG.md +109 -3
- package/cli/command.js +6 -6
- package/lib/templates/_client.tpl.d.ts +7 -4
- package/lib/templates/_client.tpl.ts +8 -4
- package/lib/util.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
# [2.0.0-
|
|
6
|
+
# [2.0.0-beta.10](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.9...@spec2ts/openapi-client@2.0.0-beta.10) (2022-06-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **openapi-client:** upgrade to typescript 4 ([932877f](https://github.com/touchifyapp/spec2ts/commit/932877f83915a953400b41fc74ea921aeaed3b1d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [2.0.0-beta.9](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.8...@spec2ts/openapi-client@2.0.0-beta.9) (2022-01-27)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [2.0.0-beta.8](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.7...@spec2ts/openapi-client@2.0.0-beta.8) (2021-11-03)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [2.0.0-beta.7](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.6...@spec2ts/openapi-client@2.0.0-beta.7) (2021-10-23)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
9
36
|
|
|
@@ -11,12 +38,75 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
38
|
|
|
12
39
|
|
|
13
40
|
|
|
14
|
-
# [2.0.0-
|
|
41
|
+
# [2.0.0-beta.6](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.5...@spec2ts/openapi-client@2.0.0-beta.6) (2021-02-27)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [2.0.0-beta.5](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.4...@spec2ts/openapi-client@2.0.0-beta.5) (2020-12-21)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
* **openapi-client:** allow $ and _ in camelCase ([08c244e](https://github.com/touchifyapp/spec2ts/commit/08c244eb6e2c0a6f3ab833faa5159483ca1adda7))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# [2.0.0-beta.4](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.3...@spec2ts/openapi-client@2.0.0-beta.4) (2020-12-14)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
* **openapi-client:** type issue in TS 4.1 ([09da142](https://github.com/touchifyapp/spec2ts/commit/09da1423ce16e1a8ccee81ba0ad160f5f6313a67))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# [2.0.0-beta.3](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.2...@spec2ts/openapi-client@2.0.0-beta.3) (2020-11-29)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
* **openapi:** bad yargs options for enableDate ([cc799cb](https://github.com/touchifyapp/spec2ts/commit/cc799cb14600f5a5388a825932622251ed1df19c))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [2.0.0-beta.2](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.1...@spec2ts/openapi-client@2.0.0-beta.2) (2020-11-29)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
* **openapi-client:** add support for new lax date style ([73ac242](https://github.com/touchifyapp/spec2ts/commit/73ac2428cf7195817cc66c41a9e18fa6e9a7abee))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# [2.0.0-beta.1](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@2.0.0-beta.0...@spec2ts/openapi-client@2.0.0-beta.1) (2020-11-16)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Bug Fixes
|
|
97
|
+
|
|
98
|
+
* **openapi-client:** improve types for TypeScript v4 ([7927e7b](https://github.com/touchifyapp/spec2ts/commit/7927e7ba48f5abf03f0a51972213f9034cf5f09d))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [2.0.0-beta.0](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@1.4.3...@spec2ts/openapi-client@2.0.0-beta.0) (2020-11-13)
|
|
15
105
|
|
|
16
106
|
|
|
17
107
|
### Features
|
|
18
108
|
|
|
19
|
-
* **global:** upgrade typescript 4 ([#16](https://github.com/touchifyapp/spec2ts/issues/16)) ([
|
|
109
|
+
* **global:** upgrade typescript 4 ([#16](https://github.com/touchifyapp/spec2ts/issues/16)) ([fcd82be](https://github.com/touchifyapp/spec2ts/commit/fcd82be93be3986a2f723680f1c52818eb7ba1bc))
|
|
20
110
|
|
|
21
111
|
|
|
22
112
|
### BREAKING CHANGES
|
|
@@ -28,6 +118,22 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
28
118
|
|
|
29
119
|
|
|
30
120
|
|
|
121
|
+
## [1.4.3](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@1.4.2...@spec2ts/openapi-client@1.4.3) (2020-10-26)
|
|
122
|
+
|
|
123
|
+
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## [1.4.2](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@1.4.1...@spec2ts/openapi-client@1.4.2) (2020-10-26)
|
|
130
|
+
|
|
131
|
+
**Note:** Version bump only for package @spec2ts/openapi-client
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
31
137
|
## [1.4.1](https://github.com/touchifyapp/spec2ts/compare/@spec2ts/openapi-client@1.4.0...@spec2ts/openapi-client@1.4.1) (2020-10-06)
|
|
32
138
|
|
|
33
139
|
|
package/cli/command.js
CHANGED
|
@@ -29,10 +29,10 @@ function builder(argv) {
|
|
|
29
29
|
type: "boolean",
|
|
30
30
|
describe: "Avoid the `any` type and use `unknown` instead"
|
|
31
31
|
})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
.option("enableDate", {
|
|
33
|
+
choices: [true, "strict", "lax"],
|
|
34
|
+
describe: "Build `Date` for format `date` and `date-time`"
|
|
35
|
+
})
|
|
36
36
|
.option("inlineRequired", {
|
|
37
37
|
type: "boolean",
|
|
38
38
|
describe: "Create a method argument for each required parameter"
|
|
@@ -140,12 +140,12 @@ async function generatePackage(output, options) {
|
|
|
140
140
|
main: main.replace(/\.ts$/, ".js"),
|
|
141
141
|
files: ["*.js", "*.d.ts"],
|
|
142
142
|
scripts: {
|
|
143
|
-
build: `tsc ${main} --strict --target ${options.packageBuildTarget || "ES2018"} --module ${options.packageBuildModule || "UMD"} --moduleResolution node`,
|
|
143
|
+
build: `tsc ${main} --strict --target ${options.packageBuildTarget || "ES2018"} --module ${options.packageBuildModule || "UMD"} --moduleResolution node --skipLibCheck`,
|
|
144
144
|
prepublishOnly: "npm run build"
|
|
145
145
|
},
|
|
146
146
|
dependencies: {},
|
|
147
147
|
devDependencies: {
|
|
148
|
-
typescript: "^
|
|
148
|
+
typescript: "^4.2.0"
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
if (options.importFetch) {
|
|
@@ -17,17 +17,20 @@ declare type FetchRequestOptions = RequestOptions & {
|
|
|
17
17
|
body?: string | FormData;
|
|
18
18
|
};
|
|
19
19
|
declare type JsonRequestOptions = RequestOptions & {
|
|
20
|
-
body:
|
|
20
|
+
body: unknown;
|
|
21
|
+
};
|
|
22
|
+
declare type FormRequestOptions<T extends Record<string, unknown>> = RequestOptions & {
|
|
23
|
+
body: T;
|
|
21
24
|
};
|
|
22
25
|
declare type MultipartRequestOptions = RequestOptions & {
|
|
23
|
-
body: Record<string,
|
|
26
|
+
body: Record<string, any>;
|
|
24
27
|
};
|
|
25
28
|
/** Utilities functions */
|
|
26
29
|
export declare const _: {
|
|
27
30
|
encodeReserved: (typeof encodeURI)[];
|
|
28
31
|
allowReserved: (typeof encodeURI)[];
|
|
29
32
|
/** Deeply remove all properties with undefined values. */
|
|
30
|
-
stripUndefined<T>(obj?: T | undefined):
|
|
33
|
+
stripUndefined<T extends Record<string, U | undefined>, U>(obj?: T | undefined): Record<string, U> | undefined;
|
|
31
34
|
isEmpty(v: unknown): boolean;
|
|
32
35
|
/** Creates a tag-function to encode template strings with the given encoders. */
|
|
33
36
|
encode(encoders: Encoders, delimiter?: string): TagFunction;
|
|
@@ -62,7 +65,7 @@ export declare const http: {
|
|
|
62
65
|
fetchJson(url: string, req?: FetchRequestOptions): Promise<ApiResponse<any>>;
|
|
63
66
|
fetchVoid(url: string, req?: FetchRequestOptions): Promise<ApiResponse<undefined>>;
|
|
64
67
|
json({ body, headers, ...req }: JsonRequestOptions): FetchRequestOptions;
|
|
65
|
-
form({ body, headers, ...req }:
|
|
68
|
+
form<T extends Record<string, unknown>>({ body, headers, ...req }: FormRequestOptions<T>): FetchRequestOptions;
|
|
66
69
|
multipart({ body, ...req }: MultipartRequestOptions): FetchRequestOptions;
|
|
67
70
|
headers(headers: Headers): Record<string, string>;
|
|
68
71
|
};
|
|
@@ -25,11 +25,15 @@ type FetchRequestOptions = RequestOptions & {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
type JsonRequestOptions = RequestOptions & {
|
|
28
|
-
body:
|
|
28
|
+
body: unknown;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type FormRequestOptions<T extends Record<string, unknown>> = RequestOptions & {
|
|
32
|
+
body: T;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
35
|
type MultipartRequestOptions = RequestOptions & {
|
|
32
|
-
body: Record<string, string | Blob
|
|
36
|
+
body: Record<string, any>; // string | Blob
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
/** Utilities functions */
|
|
@@ -39,7 +43,7 @@ export const _ = {
|
|
|
39
43
|
allowReserved: [encodeURI, encodeURI],
|
|
40
44
|
|
|
41
45
|
/** Deeply remove all properties with undefined values. */
|
|
42
|
-
stripUndefined<T>(obj?: T):
|
|
46
|
+
stripUndefined<T extends Record<string, U | undefined>, U>(obj?: T): Record<string, U> | undefined {
|
|
43
47
|
return obj && JSON.parse(JSON.stringify(obj));
|
|
44
48
|
},
|
|
45
49
|
|
|
@@ -215,7 +219,7 @@ export const http = {
|
|
|
215
219
|
};
|
|
216
220
|
},
|
|
217
221
|
|
|
218
|
-
form({ body, headers, ...req }:
|
|
222
|
+
form<T extends Record<string, unknown>>({ body, headers, ...req }: FormRequestOptions<T>): FetchRequestOptions {
|
|
219
223
|
return {
|
|
220
224
|
...req,
|
|
221
225
|
body: QS.form(body),
|
package/lib/util.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.camelCase = void 0;
|
|
4
4
|
function camelCase(str) {
|
|
5
|
-
const regex = /[A-Z\xC0-\xD6\xD8-\
|
|
5
|
+
const regex = /[A-Z\xC0-\xD6\xD8-\xDE_$]?[a-z\xDF-\xF6\xF8-\xFF_$]+|[A-Z\xC0-\xD6\xD8-\xDE_$]+(?![a-z\xDF-\xF6\xF8-\xFF_$])|\d+/g;
|
|
6
6
|
const words = str.match(regex);
|
|
7
7
|
if (!words)
|
|
8
8
|
return "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spec2ts/openapi-client",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "Utility to convert OpenAPI v3 specifications to Typescript HTTP client using TypeScript native compiler",
|
|
5
5
|
"author": "Touchify <dev@touchify.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"prepublishOnly": "npm test && npm run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@spec2ts/core": "^2.0.0-
|
|
44
|
-
"@spec2ts/jsonschema": "^2.0.0-
|
|
45
|
-
"@spec2ts/openapi": "^2.0.0-
|
|
43
|
+
"@spec2ts/core": "^2.0.0-beta.2",
|
|
44
|
+
"@spec2ts/jsonschema": "^2.0.0-beta.6",
|
|
45
|
+
"@spec2ts/openapi": "^2.0.0-beta.6",
|
|
46
46
|
"openapi3-ts": "^1.3.0",
|
|
47
47
|
"yargs": "^15.3.1"
|
|
48
48
|
},
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"spec2ts",
|
|
71
71
|
"share"
|
|
72
72
|
],
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "bce454934149bbb6cd4e26e85b923642c6038b16"
|
|
74
74
|
}
|