@hey-api/openapi-ts 0.28.0 → 0.29.1
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/README.md +1 -0
- package/bin/index.js +1 -0
- package/dist/node/index.d.ts +104 -98
- package/dist/node/index.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -189,6 +189,7 @@ $ openapi-ts --help
|
|
|
189
189
|
--postfixModels Model name postfix
|
|
190
190
|
--request <value> Path to custom request file
|
|
191
191
|
--useDateType <value> Output Date instead of string for the format "date-time" in the models (default: false)
|
|
192
|
+
--useLegacyEnums Generate Typescript enum definitions (default: false)
|
|
192
193
|
-h, --help display help for command
|
|
193
194
|
```
|
|
194
195
|
|
package/bin/index.js
CHANGED
|
@@ -36,6 +36,7 @@ const params = program
|
|
|
36
36
|
.option('--request <value>', 'Path to custom request file')
|
|
37
37
|
.option('--write', 'Write files to disk? (used for testing)')
|
|
38
38
|
.option('--no-write', 'Skip writing files to disk (used for testing)')
|
|
39
|
+
.option('--useLegacyEnums', 'Generate Typescript enum definitions')
|
|
39
40
|
.parse(process.argv)
|
|
40
41
|
.opts();
|
|
41
42
|
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,101 +1,3 @@
|
|
|
1
|
-
interface Enum {
|
|
2
|
-
'x-enum-description'?: string;
|
|
3
|
-
'x-enum-varname'?: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
value: string | number;
|
|
6
|
-
}
|
|
7
|
-
interface OperationError {
|
|
8
|
-
code: number;
|
|
9
|
-
description: string;
|
|
10
|
-
}
|
|
11
|
-
interface OperationParameter extends Model {
|
|
12
|
-
in: 'path' | 'query' | 'header' | 'formData' | 'body' | 'cookie';
|
|
13
|
-
prop: string;
|
|
14
|
-
mediaType: string | null;
|
|
15
|
-
}
|
|
16
|
-
interface OperationParameters extends Pick<Model, '$refs' | 'imports'> {
|
|
17
|
-
parameters: OperationParameter[];
|
|
18
|
-
parametersBody: OperationParameter | null;
|
|
19
|
-
parametersCookie: OperationParameter[];
|
|
20
|
-
parametersForm: OperationParameter[];
|
|
21
|
-
parametersHeader: OperationParameter[];
|
|
22
|
-
parametersPath: OperationParameter[];
|
|
23
|
-
parametersQuery: OperationParameter[];
|
|
24
|
-
}
|
|
25
|
-
interface OperationResponse extends Model {
|
|
26
|
-
in: 'response' | 'header';
|
|
27
|
-
code: number;
|
|
28
|
-
}
|
|
29
|
-
interface Operation extends OperationParameters {
|
|
30
|
-
deprecated: boolean;
|
|
31
|
-
description: string | null;
|
|
32
|
-
errors: OperationError[];
|
|
33
|
-
method: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
|
|
34
|
-
/**
|
|
35
|
-
* Method name. Methods contain the request logic.
|
|
36
|
-
*/
|
|
37
|
-
name: string;
|
|
38
|
-
path: string;
|
|
39
|
-
responseHeader: string | null;
|
|
40
|
-
results: OperationResponse[];
|
|
41
|
-
/**
|
|
42
|
-
* Service name, might be without postfix. This will be used to name the
|
|
43
|
-
* exported class.
|
|
44
|
-
*/
|
|
45
|
-
service: string;
|
|
46
|
-
summary: string | null;
|
|
47
|
-
}
|
|
48
|
-
interface Schema {
|
|
49
|
-
exclusiveMaximum?: boolean;
|
|
50
|
-
exclusiveMinimum?: boolean;
|
|
51
|
-
format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string';
|
|
52
|
-
isDefinition: boolean;
|
|
53
|
-
isNullable: boolean;
|
|
54
|
-
isReadOnly: boolean;
|
|
55
|
-
isRequired: boolean;
|
|
56
|
-
maximum?: number;
|
|
57
|
-
maxItems?: number;
|
|
58
|
-
maxLength?: number;
|
|
59
|
-
maxProperties?: number;
|
|
60
|
-
minimum?: number;
|
|
61
|
-
minItems?: number;
|
|
62
|
-
minLength?: number;
|
|
63
|
-
minProperties?: number;
|
|
64
|
-
multipleOf?: number;
|
|
65
|
-
pattern?: string;
|
|
66
|
-
uniqueItems?: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface Model extends Schema {
|
|
69
|
-
/**
|
|
70
|
-
* **Experimental.** Contains list of original refs so they can be used
|
|
71
|
-
* to access the schema from anywhere instead of relying on string name.
|
|
72
|
-
* This allows us to do things like detect type of ref.
|
|
73
|
-
*/
|
|
74
|
-
$refs: string[];
|
|
75
|
-
base: string;
|
|
76
|
-
default?: string;
|
|
77
|
-
deprecated?: boolean;
|
|
78
|
-
description: string | null;
|
|
79
|
-
enum: Enum[];
|
|
80
|
-
enums: Model[];
|
|
81
|
-
export: 'all-of' | 'any-of' | 'array' | 'const' | 'dictionary' | 'enum' | 'generic' | 'interface' | 'one-of' | 'reference';
|
|
82
|
-
imports: string[];
|
|
83
|
-
link: Model | null;
|
|
84
|
-
name: string;
|
|
85
|
-
properties: Model[];
|
|
86
|
-
template: string | null;
|
|
87
|
-
type: string;
|
|
88
|
-
}
|
|
89
|
-
interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
|
|
90
|
-
operations: Operation[];
|
|
91
|
-
}
|
|
92
|
-
interface Client {
|
|
93
|
-
models: Model[];
|
|
94
|
-
server: string;
|
|
95
|
-
services: Service[];
|
|
96
|
-
version: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
1
|
interface UserConfig {
|
|
100
2
|
/**
|
|
101
3
|
* Manually set base in OpenAPI config instead of inferring from server value
|
|
@@ -187,6 +89,11 @@ interface UserConfig {
|
|
|
187
89
|
* @default true
|
|
188
90
|
*/
|
|
189
91
|
useOptions?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Generate Typescript enum definitions
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
useLegacyEnums?: boolean;
|
|
190
97
|
/**
|
|
191
98
|
* Write the files to disk (true or false)
|
|
192
99
|
* @default true
|
|
@@ -194,6 +101,105 @@ interface UserConfig {
|
|
|
194
101
|
write?: boolean;
|
|
195
102
|
}
|
|
196
103
|
|
|
104
|
+
interface Enum {
|
|
105
|
+
'x-enum-description'?: string;
|
|
106
|
+
'x-enum-varname'?: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
value: string | number;
|
|
109
|
+
}
|
|
110
|
+
interface OperationError {
|
|
111
|
+
code: number;
|
|
112
|
+
description: string;
|
|
113
|
+
}
|
|
114
|
+
interface OperationParameter extends Model {
|
|
115
|
+
in: 'path' | 'query' | 'header' | 'formData' | 'body' | 'cookie';
|
|
116
|
+
prop: string;
|
|
117
|
+
mediaType: string | null;
|
|
118
|
+
}
|
|
119
|
+
interface OperationParameters extends Pick<Model, '$refs' | 'imports'> {
|
|
120
|
+
parameters: OperationParameter[];
|
|
121
|
+
parametersBody: OperationParameter | null;
|
|
122
|
+
parametersCookie: OperationParameter[];
|
|
123
|
+
parametersForm: OperationParameter[];
|
|
124
|
+
parametersHeader: OperationParameter[];
|
|
125
|
+
parametersPath: OperationParameter[];
|
|
126
|
+
parametersQuery: OperationParameter[];
|
|
127
|
+
}
|
|
128
|
+
interface OperationResponse extends Model {
|
|
129
|
+
in: 'response' | 'header';
|
|
130
|
+
code: number;
|
|
131
|
+
}
|
|
132
|
+
interface Operation extends OperationParameters {
|
|
133
|
+
deprecated: boolean;
|
|
134
|
+
description: string | null;
|
|
135
|
+
errors: OperationError[];
|
|
136
|
+
method: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
|
|
137
|
+
/**
|
|
138
|
+
* Method name. Methods contain the request logic.
|
|
139
|
+
*/
|
|
140
|
+
name: string;
|
|
141
|
+
path: string;
|
|
142
|
+
responseHeader: string | null;
|
|
143
|
+
results: OperationResponse[];
|
|
144
|
+
/**
|
|
145
|
+
* Service name, might be without postfix. This will be used to name the
|
|
146
|
+
* exported class.
|
|
147
|
+
*/
|
|
148
|
+
service: string;
|
|
149
|
+
summary: string | null;
|
|
150
|
+
}
|
|
151
|
+
interface Schema {
|
|
152
|
+
exclusiveMaximum?: boolean;
|
|
153
|
+
exclusiveMinimum?: boolean;
|
|
154
|
+
format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string';
|
|
155
|
+
isDefinition: boolean;
|
|
156
|
+
isNullable: boolean;
|
|
157
|
+
isReadOnly: boolean;
|
|
158
|
+
isRequired: boolean;
|
|
159
|
+
maximum?: number;
|
|
160
|
+
maxItems?: number;
|
|
161
|
+
maxLength?: number;
|
|
162
|
+
maxProperties?: number;
|
|
163
|
+
minimum?: number;
|
|
164
|
+
minItems?: number;
|
|
165
|
+
minLength?: number;
|
|
166
|
+
minProperties?: number;
|
|
167
|
+
multipleOf?: number;
|
|
168
|
+
pattern?: string;
|
|
169
|
+
uniqueItems?: boolean;
|
|
170
|
+
}
|
|
171
|
+
interface Model extends Schema {
|
|
172
|
+
/**
|
|
173
|
+
* **Experimental.** Contains list of original refs so they can be used
|
|
174
|
+
* to access the schema from anywhere instead of relying on string name.
|
|
175
|
+
* This allows us to do things like detect type of ref.
|
|
176
|
+
*/
|
|
177
|
+
$refs: string[];
|
|
178
|
+
base: string;
|
|
179
|
+
default?: string;
|
|
180
|
+
deprecated?: boolean;
|
|
181
|
+
description: string | null;
|
|
182
|
+
enum: Enum[];
|
|
183
|
+
enums: Model[];
|
|
184
|
+
export: 'all-of' | 'any-of' | 'array' | 'const' | 'dictionary' | 'enum' | 'generic' | 'interface' | 'one-of' | 'reference';
|
|
185
|
+
imports: string[];
|
|
186
|
+
link: Model | null;
|
|
187
|
+
name: string;
|
|
188
|
+
properties: Model[];
|
|
189
|
+
template: string | null;
|
|
190
|
+
type: string;
|
|
191
|
+
}
|
|
192
|
+
interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
|
|
193
|
+
operations: Operation[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface Client {
|
|
197
|
+
models: Model[];
|
|
198
|
+
server: string;
|
|
199
|
+
services: Service[];
|
|
200
|
+
version: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
197
203
|
/**
|
|
198
204
|
* Generate the OpenAPI client. This method will read the OpenAPI specification and based on the
|
|
199
205
|
* given language it will generate the client, including the typed models, validation schemas,
|