@goast/typescript 0.5.3-beta.1 → 0.6.0-beta.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/assets/client/k6/request-builder.ts +362 -362
- package/esm/src/file-builder.d.ts.map +1 -1
- package/esm/src/file-builder.js +2 -5
- package/esm/src/generators/models/model-generator.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.js +6 -2
- package/esm/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/k6-clients/k6-client-generator.js +2 -1
- package/package.json +3 -3
- package/script/src/file-builder.d.ts.map +1 -1
- package/script/src/file-builder.js +1 -5
- package/script/src/generators/models/model-generator.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.js +5 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.js +2 -1
|
@@ -1,362 +1,362 @@
|
|
|
1
|
-
// @deno-types="npm:@types/k6/http"
|
|
2
|
-
import http, { Params, Response } from 'k6/http';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Defines the options for appending a parameter
|
|
8
|
-
*/
|
|
9
|
-
type ParameterOptions = {
|
|
10
|
-
style?: string;
|
|
11
|
-
explode?: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type BuildOptions = {
|
|
15
|
-
accept?: string;
|
|
16
|
-
params?: Params;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Base class for a parameter
|
|
21
|
-
*/
|
|
22
|
-
abstract class Parameter {
|
|
23
|
-
public readonly name: string;
|
|
24
|
-
public readonly value: any;
|
|
25
|
-
public readonly options: ParameterOptions;
|
|
26
|
-
|
|
27
|
-
constructor(name: string, value: any, options: ParameterOptions, defaultStyle: string, defaultExplode: boolean) {
|
|
28
|
-
this.name = name;
|
|
29
|
-
this.value = value;
|
|
30
|
-
this.options = options || {};
|
|
31
|
-
if (this.options.style === null || this.options.style === undefined) {
|
|
32
|
-
this.options.style = defaultStyle;
|
|
33
|
-
}
|
|
34
|
-
if (this.options.explode === null || this.options.explode === undefined) {
|
|
35
|
-
this.options.explode = defaultExplode;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public serializeValue(value: any, separator = ','): string {
|
|
40
|
-
if (value === null || value === undefined) {
|
|
41
|
-
return '';
|
|
42
|
-
} else if (value instanceof Array) {
|
|
43
|
-
return value
|
|
44
|
-
.map((v) => this.serializeValue(v).split(separator).join(encodeURIComponent(separator)))
|
|
45
|
-
.join(separator);
|
|
46
|
-
} else if (typeof value === 'object') {
|
|
47
|
-
const array: string[] = [];
|
|
48
|
-
for (const key of Object.keys(value)) {
|
|
49
|
-
let propVal = value[key];
|
|
50
|
-
if (propVal !== null && propVal !== undefined) {
|
|
51
|
-
propVal = this.serializeValue(propVal).split(separator).join(encodeURIComponent(separator));
|
|
52
|
-
if (this.options.explode) {
|
|
53
|
-
array.push(`${key}=${propVal}`);
|
|
54
|
-
} else {
|
|
55
|
-
array.push(key);
|
|
56
|
-
array.push(propVal);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return array.join(separator);
|
|
61
|
-
} else {
|
|
62
|
-
return String(value);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* A parameter in the operation path
|
|
69
|
-
*/
|
|
70
|
-
class PathParameter extends Parameter {
|
|
71
|
-
constructor(name: string, value: any, options: ParameterOptions) {
|
|
72
|
-
super(name, value, options, 'simple', false);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public append(path: string): string {
|
|
76
|
-
let value = this.value;
|
|
77
|
-
if (value === null || value === undefined) {
|
|
78
|
-
value = '';
|
|
79
|
-
}
|
|
80
|
-
let prefix = this.options.style === 'label' ? '.' : '';
|
|
81
|
-
const separator = this.options.explode ? (prefix === '' ? ',' : prefix) : ',';
|
|
82
|
-
let alreadySerialized = false;
|
|
83
|
-
if (this.options.style === 'matrix') {
|
|
84
|
-
// The parameter name is just used as prefix, except in some cases...
|
|
85
|
-
prefix = `;${this.name}=`;
|
|
86
|
-
if (this.options.explode && typeof value === 'object') {
|
|
87
|
-
prefix = ';';
|
|
88
|
-
if (value instanceof Array) {
|
|
89
|
-
// For arrays we have to repeat the name for each element
|
|
90
|
-
value = value.map((v) => `${this.name}=${this.serializeValue(v, ';')}`);
|
|
91
|
-
value = value.join(';');
|
|
92
|
-
alreadySerialized = true;
|
|
93
|
-
} else {
|
|
94
|
-
// For objects we have to put each the key / value pairs
|
|
95
|
-
value = this.serializeValue(value, ';');
|
|
96
|
-
alreadySerialized = true;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
value = prefix + (alreadySerialized ? value : this.serializeValue(value, separator));
|
|
101
|
-
// Replace both the plain variable and the corresponding variant taking in the prefix and explode into account
|
|
102
|
-
path = path.replace(`{${this.name}}`, value);
|
|
103
|
-
path = path.replace(`{${prefix}${this.name}${this.options.explode ? '*' : ''}}`, value);
|
|
104
|
-
return path;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public override serializeValue(value: any, separator = ','): string {
|
|
108
|
-
let result = typeof value === 'string' ? encodeURIComponent(value) : super.serializeValue(value, separator);
|
|
109
|
-
result = result.replace(/%3D/g, '=');
|
|
110
|
-
result = result.replace(/%3B/g, ';');
|
|
111
|
-
result = result.replace(/%2C/g, ',');
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* A parameter in the query
|
|
118
|
-
*/
|
|
119
|
-
class QueryParameter extends Parameter {
|
|
120
|
-
constructor(name: string, value: any, options: ParameterOptions) {
|
|
121
|
-
super(name, value, options, 'form', true);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public append(params: string): string {
|
|
125
|
-
if (this.value instanceof Array) {
|
|
126
|
-
// Array serialization
|
|
127
|
-
if (this.options.explode) {
|
|
128
|
-
for (const v of this.value) {
|
|
129
|
-
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(v)}`;
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
const separator = this.options.style === 'spaceDelimited'
|
|
133
|
-
? ' '
|
|
134
|
-
: this.options.style === 'pipeDelimited'
|
|
135
|
-
? '|'
|
|
136
|
-
: ',';
|
|
137
|
-
return `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${
|
|
138
|
-
this.serializeValue(this.value, separator)
|
|
139
|
-
}`;
|
|
140
|
-
}
|
|
141
|
-
} else if (this.value !== null && typeof this.value === 'object') {
|
|
142
|
-
// Object serialization
|
|
143
|
-
if (this.options.style === 'deepObject') {
|
|
144
|
-
// Append a parameter for each key, in the form `name[key]`
|
|
145
|
-
for (const key of Object.keys(this.value)) {
|
|
146
|
-
const propVal = this.value[key];
|
|
147
|
-
if (propVal !== null && propVal !== undefined) {
|
|
148
|
-
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}[${
|
|
149
|
-
encodeURIComponent(
|
|
150
|
-
key,
|
|
151
|
-
)
|
|
152
|
-
}]=${this.serializeValue(propVal)}`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
} else if (this.options.explode) {
|
|
156
|
-
// Append a parameter for each key without using the parameter name
|
|
157
|
-
for (const key of Object.keys(this.value)) {
|
|
158
|
-
const propVal = this.value[key];
|
|
159
|
-
if (propVal !== null && propVal !== undefined) {
|
|
160
|
-
params = `${params}${params ? '&' : '?'}${encodeURIComponent(key)}=${this.serializeValue(propVal)}`;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
// Append a single parameter whose values are a comma-separated list of key,value,key,value...
|
|
165
|
-
const array: unknown[] = [];
|
|
166
|
-
for (const key of Object.keys(this.value)) {
|
|
167
|
-
const propVal = this.value[key];
|
|
168
|
-
if (propVal !== null && propVal !== undefined) {
|
|
169
|
-
array.push(key);
|
|
170
|
-
array.push(propVal);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(array)}`;
|
|
174
|
-
}
|
|
175
|
-
} else if (this.value !== null && this.value !== undefined) {
|
|
176
|
-
// Plain value
|
|
177
|
-
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(this.value)}`;
|
|
178
|
-
}
|
|
179
|
-
return params;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* A parameter in the HTTP request header
|
|
185
|
-
*/
|
|
186
|
-
class HeaderParameter extends Parameter {
|
|
187
|
-
constructor(name: string, value: any, options: ParameterOptions) {
|
|
188
|
-
super(name, value, options, 'simple', false);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
public append(headers: Record<string, string>): Record<string, string> {
|
|
192
|
-
if (this.value !== null && this.value !== undefined) {
|
|
193
|
-
if (this.value instanceof Array) {
|
|
194
|
-
throw new Error('Array header values are not supported');
|
|
195
|
-
} else {
|
|
196
|
-
headers[this.name] = this.serializeValue(this.value);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return headers;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Helper to build http requests from parameters
|
|
205
|
-
*/
|
|
206
|
-
export class RequestBuilder {
|
|
207
|
-
private readonly _path: Map<string, PathParameter>;
|
|
208
|
-
private readonly _query: Map<string, QueryParameter>;
|
|
209
|
-
private readonly _header: Map<string, HeaderParameter>;
|
|
210
|
-
private _bodyContent: any;
|
|
211
|
-
private _bodyContentType: string | undefined;
|
|
212
|
-
|
|
213
|
-
public readonly rootUrl: string;
|
|
214
|
-
public readonly operationPath: string;
|
|
215
|
-
public readonly method: string;
|
|
216
|
-
|
|
217
|
-
constructor(rootUrl: string, operationPath: string, method: string) {
|
|
218
|
-
this.rootUrl = rootUrl;
|
|
219
|
-
this.operationPath = operationPath;
|
|
220
|
-
this.method = method;
|
|
221
|
-
this._path = new Map();
|
|
222
|
-
this._query = new Map();
|
|
223
|
-
this._header = new Map();
|
|
224
|
-
this._bodyContent = null;
|
|
225
|
-
this._bodyContentType = undefined;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Sets a path parameter
|
|
230
|
-
*/
|
|
231
|
-
public path(name: string, value: any, options: ParameterOptions) {
|
|
232
|
-
this._path.set(name, new PathParameter(name, value, options || {}));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Sets a query parameter
|
|
237
|
-
*/
|
|
238
|
-
public query(name: string, value: any, options: ParameterOptions) {
|
|
239
|
-
this._query.set(name, new QueryParameter(name, value, options || {}));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Sets a header parameter
|
|
244
|
-
*/
|
|
245
|
-
public header(name: string, value: any, options: ParameterOptions) {
|
|
246
|
-
this._header.set(name, new HeaderParameter(name, value, options || {}));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Sets the body content, along with the content type
|
|
251
|
-
*/
|
|
252
|
-
public body(value: any, contentType = 'application/json') {
|
|
253
|
-
this._bodyContentType = contentType;
|
|
254
|
-
if (this._bodyContentType === 'application/x-www-form-urlencoded' && value !== null && typeof value === 'object') {
|
|
255
|
-
// Handle URL-encoded data
|
|
256
|
-
const pairs: [string, string][] = [];
|
|
257
|
-
for (const key of Object.keys(value)) {
|
|
258
|
-
let val = value[key];
|
|
259
|
-
if (!(val instanceof Array)) {
|
|
260
|
-
val = [val];
|
|
261
|
-
}
|
|
262
|
-
for (const v of val) {
|
|
263
|
-
const formValue = this.formDataValue(v);
|
|
264
|
-
if (formValue !== null) {
|
|
265
|
-
pairs.push([key, formValue]);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
this._bodyContent = pairs.map((p) => `${encodeURIComponent(p[0])}=${encodeURIComponent(p[1])}`).join('&');
|
|
270
|
-
} else if (this._bodyContentType === 'multipart/form-data' && value !== null && typeof value === 'object') {
|
|
271
|
-
const fd = new FormData();
|
|
272
|
-
for (const key in value) {
|
|
273
|
-
fd.append(key, this.formDataValue(value[key]));
|
|
274
|
-
}
|
|
275
|
-
this._bodyContent = fd.body();
|
|
276
|
-
this._bodyContentType = 'multipart/form-data; boundary=' + fd.boundary;
|
|
277
|
-
} else if (this._bodyContentType.indexOf('json') !== -1 && value !== null && typeof value === 'object') {
|
|
278
|
-
this._bodyContent = JSON.stringify(value);
|
|
279
|
-
} else {
|
|
280
|
-
// The body is the plain content
|
|
281
|
-
this._bodyContent = value;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
private formDataValue(value: any): any {
|
|
286
|
-
if (value === null || value === undefined) {
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
if (this.isFile(value)) {
|
|
290
|
-
return value;
|
|
291
|
-
}
|
|
292
|
-
return { data: JSON.stringify(value), content_type: 'application/json' };
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
private isFile(value: any): value is http.FileData {
|
|
296
|
-
return (
|
|
297
|
-
typeof value === 'object' &&
|
|
298
|
-
value !== null &&
|
|
299
|
-
'data' in value &&
|
|
300
|
-
(typeof value.data === 'string' || value.data instanceof ArrayBuffer) &&
|
|
301
|
-
(!('filename' in value) || typeof value.filename === 'string') &&
|
|
302
|
-
(!('content_type' in value) || typeof value.content_type === 'string') &&
|
|
303
|
-
Object.keys(value).every((key) => key === 'data' || key === 'filename' || key === 'content_type')
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Builds the request with the current set parameters
|
|
309
|
-
*/
|
|
310
|
-
public build(options?: BuildOptions): Response {
|
|
311
|
-
// Perform the request
|
|
312
|
-
return http.request(...this.buildRequestParams(options));
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Builds the request with the current set parameters
|
|
317
|
-
*/
|
|
318
|
-
public buildAsync(options?: BuildOptions): Promise<Response> {
|
|
319
|
-
// Perform the request
|
|
320
|
-
return http.asyncRequest(...this.buildRequestParams(options));
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private buildRequestParams(options?: BuildOptions): Parameters<typeof http.request> {
|
|
324
|
-
options = options || {};
|
|
325
|
-
|
|
326
|
-
// Path parameters
|
|
327
|
-
let path = this.operationPath;
|
|
328
|
-
for (const pathParam of this._path.values()) {
|
|
329
|
-
path = pathParam.append(path);
|
|
330
|
-
}
|
|
331
|
-
const url = this.rootUrl + path;
|
|
332
|
-
|
|
333
|
-
// Query parameters
|
|
334
|
-
let httpParams = '';
|
|
335
|
-
for (const queryParam of this._query.values()) {
|
|
336
|
-
httpParams = queryParam.append(httpParams);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Header parameters
|
|
340
|
-
let httpHeaders: Record<string, string> = {};
|
|
341
|
-
if (options.accept) {
|
|
342
|
-
httpHeaders['Accept'] = options.accept;
|
|
343
|
-
}
|
|
344
|
-
for (const headerParam of this._header.values()) {
|
|
345
|
-
httpHeaders = headerParam.append(httpHeaders);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// Request content headers
|
|
349
|
-
if (this._bodyContentType) {
|
|
350
|
-
httpHeaders['Content-Type'] = this._bodyContentType;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return [
|
|
354
|
-
this.method.toUpperCase(),
|
|
355
|
-
url + httpParams,
|
|
356
|
-
this._bodyContent,
|
|
357
|
-
Object.assign({}, options.params, {
|
|
358
|
-
headers: Object.assign({}, httpHeaders, options.params ? options.params.headers : {}),
|
|
359
|
-
}),
|
|
360
|
-
];
|
|
361
|
-
}
|
|
362
|
-
}
|
|
1
|
+
// @deno-types="npm:@types/k6/http"
|
|
2
|
+
import http, { Params, Response } from 'k6/http';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Defines the options for appending a parameter
|
|
8
|
+
*/
|
|
9
|
+
type ParameterOptions = {
|
|
10
|
+
style?: string;
|
|
11
|
+
explode?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type BuildOptions = {
|
|
15
|
+
accept?: string;
|
|
16
|
+
params?: Params;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base class for a parameter
|
|
21
|
+
*/
|
|
22
|
+
abstract class Parameter {
|
|
23
|
+
public readonly name: string;
|
|
24
|
+
public readonly value: any;
|
|
25
|
+
public readonly options: ParameterOptions;
|
|
26
|
+
|
|
27
|
+
constructor(name: string, value: any, options: ParameterOptions, defaultStyle: string, defaultExplode: boolean) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.value = value;
|
|
30
|
+
this.options = options || {};
|
|
31
|
+
if (this.options.style === null || this.options.style === undefined) {
|
|
32
|
+
this.options.style = defaultStyle;
|
|
33
|
+
}
|
|
34
|
+
if (this.options.explode === null || this.options.explode === undefined) {
|
|
35
|
+
this.options.explode = defaultExplode;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public serializeValue(value: any, separator = ','): string {
|
|
40
|
+
if (value === null || value === undefined) {
|
|
41
|
+
return '';
|
|
42
|
+
} else if (value instanceof Array) {
|
|
43
|
+
return value
|
|
44
|
+
.map((v) => this.serializeValue(v).split(separator).join(encodeURIComponent(separator)))
|
|
45
|
+
.join(separator);
|
|
46
|
+
} else if (typeof value === 'object') {
|
|
47
|
+
const array: string[] = [];
|
|
48
|
+
for (const key of Object.keys(value)) {
|
|
49
|
+
let propVal = value[key];
|
|
50
|
+
if (propVal !== null && propVal !== undefined) {
|
|
51
|
+
propVal = this.serializeValue(propVal).split(separator).join(encodeURIComponent(separator));
|
|
52
|
+
if (this.options.explode) {
|
|
53
|
+
array.push(`${key}=${propVal}`);
|
|
54
|
+
} else {
|
|
55
|
+
array.push(key);
|
|
56
|
+
array.push(propVal);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return array.join(separator);
|
|
61
|
+
} else {
|
|
62
|
+
return String(value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A parameter in the operation path
|
|
69
|
+
*/
|
|
70
|
+
class PathParameter extends Parameter {
|
|
71
|
+
constructor(name: string, value: any, options: ParameterOptions) {
|
|
72
|
+
super(name, value, options, 'simple', false);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public append(path: string): string {
|
|
76
|
+
let value = this.value;
|
|
77
|
+
if (value === null || value === undefined) {
|
|
78
|
+
value = '';
|
|
79
|
+
}
|
|
80
|
+
let prefix = this.options.style === 'label' ? '.' : '';
|
|
81
|
+
const separator = this.options.explode ? (prefix === '' ? ',' : prefix) : ',';
|
|
82
|
+
let alreadySerialized = false;
|
|
83
|
+
if (this.options.style === 'matrix') {
|
|
84
|
+
// The parameter name is just used as prefix, except in some cases...
|
|
85
|
+
prefix = `;${this.name}=`;
|
|
86
|
+
if (this.options.explode && typeof value === 'object') {
|
|
87
|
+
prefix = ';';
|
|
88
|
+
if (value instanceof Array) {
|
|
89
|
+
// For arrays we have to repeat the name for each element
|
|
90
|
+
value = value.map((v) => `${this.name}=${this.serializeValue(v, ';')}`);
|
|
91
|
+
value = value.join(';');
|
|
92
|
+
alreadySerialized = true;
|
|
93
|
+
} else {
|
|
94
|
+
// For objects we have to put each the key / value pairs
|
|
95
|
+
value = this.serializeValue(value, ';');
|
|
96
|
+
alreadySerialized = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
value = prefix + (alreadySerialized ? value : this.serializeValue(value, separator));
|
|
101
|
+
// Replace both the plain variable and the corresponding variant taking in the prefix and explode into account
|
|
102
|
+
path = path.replace(`{${this.name}}`, value);
|
|
103
|
+
path = path.replace(`{${prefix}${this.name}${this.options.explode ? '*' : ''}}`, value);
|
|
104
|
+
return path;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public override serializeValue(value: any, separator = ','): string {
|
|
108
|
+
let result = typeof value === 'string' ? encodeURIComponent(value) : super.serializeValue(value, separator);
|
|
109
|
+
result = result.replace(/%3D/g, '=');
|
|
110
|
+
result = result.replace(/%3B/g, ';');
|
|
111
|
+
result = result.replace(/%2C/g, ',');
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A parameter in the query
|
|
118
|
+
*/
|
|
119
|
+
class QueryParameter extends Parameter {
|
|
120
|
+
constructor(name: string, value: any, options: ParameterOptions) {
|
|
121
|
+
super(name, value, options, 'form', true);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public append(params: string): string {
|
|
125
|
+
if (this.value instanceof Array) {
|
|
126
|
+
// Array serialization
|
|
127
|
+
if (this.options.explode) {
|
|
128
|
+
for (const v of this.value) {
|
|
129
|
+
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(v)}`;
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
const separator = this.options.style === 'spaceDelimited'
|
|
133
|
+
? ' '
|
|
134
|
+
: this.options.style === 'pipeDelimited'
|
|
135
|
+
? '|'
|
|
136
|
+
: ',';
|
|
137
|
+
return `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${
|
|
138
|
+
this.serializeValue(this.value, separator)
|
|
139
|
+
}`;
|
|
140
|
+
}
|
|
141
|
+
} else if (this.value !== null && typeof this.value === 'object') {
|
|
142
|
+
// Object serialization
|
|
143
|
+
if (this.options.style === 'deepObject') {
|
|
144
|
+
// Append a parameter for each key, in the form `name[key]`
|
|
145
|
+
for (const key of Object.keys(this.value)) {
|
|
146
|
+
const propVal = this.value[key];
|
|
147
|
+
if (propVal !== null && propVal !== undefined) {
|
|
148
|
+
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}[${
|
|
149
|
+
encodeURIComponent(
|
|
150
|
+
key,
|
|
151
|
+
)
|
|
152
|
+
}]=${this.serializeValue(propVal)}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else if (this.options.explode) {
|
|
156
|
+
// Append a parameter for each key without using the parameter name
|
|
157
|
+
for (const key of Object.keys(this.value)) {
|
|
158
|
+
const propVal = this.value[key];
|
|
159
|
+
if (propVal !== null && propVal !== undefined) {
|
|
160
|
+
params = `${params}${params ? '&' : '?'}${encodeURIComponent(key)}=${this.serializeValue(propVal)}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
// Append a single parameter whose values are a comma-separated list of key,value,key,value...
|
|
165
|
+
const array: unknown[] = [];
|
|
166
|
+
for (const key of Object.keys(this.value)) {
|
|
167
|
+
const propVal = this.value[key];
|
|
168
|
+
if (propVal !== null && propVal !== undefined) {
|
|
169
|
+
array.push(key);
|
|
170
|
+
array.push(propVal);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(array)}`;
|
|
174
|
+
}
|
|
175
|
+
} else if (this.value !== null && this.value !== undefined) {
|
|
176
|
+
// Plain value
|
|
177
|
+
params = `${params}${params ? '&' : '?'}${encodeURIComponent(this.name)}=${this.serializeValue(this.value)}`;
|
|
178
|
+
}
|
|
179
|
+
return params;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A parameter in the HTTP request header
|
|
185
|
+
*/
|
|
186
|
+
class HeaderParameter extends Parameter {
|
|
187
|
+
constructor(name: string, value: any, options: ParameterOptions) {
|
|
188
|
+
super(name, value, options, 'simple', false);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public append(headers: Record<string, string>): Record<string, string> {
|
|
192
|
+
if (this.value !== null && this.value !== undefined) {
|
|
193
|
+
if (this.value instanceof Array) {
|
|
194
|
+
throw new Error('Array header values are not supported');
|
|
195
|
+
} else {
|
|
196
|
+
headers[this.name] = this.serializeValue(this.value);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return headers;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Helper to build http requests from parameters
|
|
205
|
+
*/
|
|
206
|
+
export class RequestBuilder {
|
|
207
|
+
private readonly _path: Map<string, PathParameter>;
|
|
208
|
+
private readonly _query: Map<string, QueryParameter>;
|
|
209
|
+
private readonly _header: Map<string, HeaderParameter>;
|
|
210
|
+
private _bodyContent: any;
|
|
211
|
+
private _bodyContentType: string | undefined;
|
|
212
|
+
|
|
213
|
+
public readonly rootUrl: string;
|
|
214
|
+
public readonly operationPath: string;
|
|
215
|
+
public readonly method: string;
|
|
216
|
+
|
|
217
|
+
constructor(rootUrl: string, operationPath: string, method: string) {
|
|
218
|
+
this.rootUrl = rootUrl;
|
|
219
|
+
this.operationPath = operationPath;
|
|
220
|
+
this.method = method;
|
|
221
|
+
this._path = new Map();
|
|
222
|
+
this._query = new Map();
|
|
223
|
+
this._header = new Map();
|
|
224
|
+
this._bodyContent = null;
|
|
225
|
+
this._bodyContentType = undefined;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Sets a path parameter
|
|
230
|
+
*/
|
|
231
|
+
public path(name: string, value: any, options: ParameterOptions) {
|
|
232
|
+
this._path.set(name, new PathParameter(name, value, options || {}));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sets a query parameter
|
|
237
|
+
*/
|
|
238
|
+
public query(name: string, value: any, options: ParameterOptions) {
|
|
239
|
+
this._query.set(name, new QueryParameter(name, value, options || {}));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Sets a header parameter
|
|
244
|
+
*/
|
|
245
|
+
public header(name: string, value: any, options: ParameterOptions) {
|
|
246
|
+
this._header.set(name, new HeaderParameter(name, value, options || {}));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Sets the body content, along with the content type
|
|
251
|
+
*/
|
|
252
|
+
public body(value: any, contentType = 'application/json') {
|
|
253
|
+
this._bodyContentType = contentType;
|
|
254
|
+
if (this._bodyContentType === 'application/x-www-form-urlencoded' && value !== null && typeof value === 'object') {
|
|
255
|
+
// Handle URL-encoded data
|
|
256
|
+
const pairs: [string, string][] = [];
|
|
257
|
+
for (const key of Object.keys(value)) {
|
|
258
|
+
let val = value[key];
|
|
259
|
+
if (!(val instanceof Array)) {
|
|
260
|
+
val = [val];
|
|
261
|
+
}
|
|
262
|
+
for (const v of val) {
|
|
263
|
+
const formValue = this.formDataValue(v);
|
|
264
|
+
if (formValue !== null) {
|
|
265
|
+
pairs.push([key, formValue]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this._bodyContent = pairs.map((p) => `${encodeURIComponent(p[0])}=${encodeURIComponent(p[1])}`).join('&');
|
|
270
|
+
} else if (this._bodyContentType === 'multipart/form-data' && value !== null && typeof value === 'object') {
|
|
271
|
+
const fd = new FormData();
|
|
272
|
+
for (const key in value) {
|
|
273
|
+
fd.append(key, this.formDataValue(value[key]));
|
|
274
|
+
}
|
|
275
|
+
this._bodyContent = fd.body();
|
|
276
|
+
this._bodyContentType = 'multipart/form-data; boundary=' + fd.boundary;
|
|
277
|
+
} else if (this._bodyContentType.indexOf('json') !== -1 && value !== null && typeof value === 'object') {
|
|
278
|
+
this._bodyContent = JSON.stringify(value);
|
|
279
|
+
} else {
|
|
280
|
+
// The body is the plain content
|
|
281
|
+
this._bodyContent = value;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private formDataValue(value: any): any {
|
|
286
|
+
if (value === null || value === undefined) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
if (this.isFile(value)) {
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
return { data: JSON.stringify(value), content_type: 'application/json' };
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private isFile(value: any): value is http.FileData {
|
|
296
|
+
return (
|
|
297
|
+
typeof value === 'object' &&
|
|
298
|
+
value !== null &&
|
|
299
|
+
'data' in value &&
|
|
300
|
+
(typeof value.data === 'string' || value.data instanceof ArrayBuffer) &&
|
|
301
|
+
(!('filename' in value) || typeof value.filename === 'string') &&
|
|
302
|
+
(!('content_type' in value) || typeof value.content_type === 'string') &&
|
|
303
|
+
Object.keys(value).every((key) => key === 'data' || key === 'filename' || key === 'content_type')
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Builds the request with the current set parameters
|
|
309
|
+
*/
|
|
310
|
+
public build(options?: BuildOptions): Response {
|
|
311
|
+
// Perform the request
|
|
312
|
+
return http.request(...this.buildRequestParams(options));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Builds the request with the current set parameters
|
|
317
|
+
*/
|
|
318
|
+
public buildAsync(options?: BuildOptions): Promise<Response> {
|
|
319
|
+
// Perform the request
|
|
320
|
+
return http.asyncRequest(...this.buildRequestParams(options));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private buildRequestParams(options?: BuildOptions): Parameters<typeof http.request> {
|
|
324
|
+
options = options || {};
|
|
325
|
+
|
|
326
|
+
// Path parameters
|
|
327
|
+
let path = this.operationPath;
|
|
328
|
+
for (const pathParam of this._path.values()) {
|
|
329
|
+
path = pathParam.append(path);
|
|
330
|
+
}
|
|
331
|
+
const url = this.rootUrl + path;
|
|
332
|
+
|
|
333
|
+
// Query parameters
|
|
334
|
+
let httpParams = '';
|
|
335
|
+
for (const queryParam of this._query.values()) {
|
|
336
|
+
httpParams = queryParam.append(httpParams);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Header parameters
|
|
340
|
+
let httpHeaders: Record<string, string> = {};
|
|
341
|
+
if (options.accept) {
|
|
342
|
+
httpHeaders['Accept'] = options.accept;
|
|
343
|
+
}
|
|
344
|
+
for (const headerParam of this._header.values()) {
|
|
345
|
+
httpHeaders = headerParam.append(httpHeaders);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Request content headers
|
|
349
|
+
if (this._bodyContentType) {
|
|
350
|
+
httpHeaders['Content-Type'] = this._bodyContentType;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return [
|
|
354
|
+
this.method.toUpperCase(),
|
|
355
|
+
url + httpParams,
|
|
356
|
+
this._bodyContent,
|
|
357
|
+
Object.assign({}, options.params, {
|
|
358
|
+
headers: Object.assign({}, httpHeaders, options.params ? options.params.headers : {}),
|
|
359
|
+
}),
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-builder.d.ts","sourceRoot":"","sources":["../../src/src/file-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-builder.d.ts","sourceRoot":"","sources":["../../src/src/file-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACt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AAE,MAAM,GAAG,IAAI;WAM7B,QAAQ,CAAC,OAAO,EAAE;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,yBAAyB,CAAC;QACpC,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACrD,GAAG,IAAI;WAIM,WAAW,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,yBAAyB,CAAC;QACpC,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACrD;CASF"}
|
package/esm/src/file-builder.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import { isAppendValue, SourceBuilder } from '@goast/core';
|
|
1
|
+
import { isAppendValue, SourceBuilder, writeGeneratedFile, } from '@goast/core';
|
|
4
2
|
import { TsNode } from './ast/node.js';
|
|
5
3
|
import { defaultTypeScriptGeneratorConfig } from './config.js';
|
|
6
4
|
import { ImportExportCollection, } from './import-collection.js';
|
|
@@ -80,8 +78,7 @@ export class TypeScriptFileBuilder extends SourceBuilder {
|
|
|
80
78
|
filePath = this.filePath;
|
|
81
79
|
if (!filePath)
|
|
82
80
|
throw new Error('File path is required');
|
|
83
|
-
|
|
84
|
-
fs.writeFileSync(filePath, this.toString());
|
|
81
|
+
writeGeneratedFile(this.options, filePath, this.toString());
|
|
85
82
|
}
|
|
86
83
|
static generate(options) {
|
|
87
84
|
TypeScriptFileBuilder.tryGenerate(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAG1B,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,+BAA+B,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAEnG,KAAK,OAAO,GAAG,+BAA+B,CAAC;AAC/C,KAAK,MAAM,GAAG,8BAA8B,CAAC;AAC7C,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACvE,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,+BAAgC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC1F,YAAW,wBAAwB;IAC5B,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IAgDnD,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,6BAA6B,GAAG,SAAS;IAQ/E,SAAS,CAAC,cAAc,CAA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SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAM7F,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { appendValueGroup, getSchemaReference, notNullish, resolveAnyOfAndAllOf, toCasing, } from '@goast/core';
|
|
2
|
+
import { appendValueGroup, DEFAULT_IGNORED_SCHEMA_PROPERTIES, getSchemaReference, notNullish, resolveAnyOfAndAllOf, toCasing, } from '@goast/core';
|
|
3
3
|
import { ts } from '../../ast/index.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
5
5
|
import { TypeScriptFileGenerator } from '../file-generator.js';
|
|
@@ -176,7 +176,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
176
176
|
getType(ctx, schema, options) {
|
|
177
177
|
if (!schema)
|
|
178
178
|
return this.getAnyType(ctx);
|
|
179
|
-
schema = getSchemaReference(schema,
|
|
179
|
+
schema = getSchemaReference(schema, DEFAULT_IGNORED_SCHEMA_PROPERTIES);
|
|
180
180
|
if ((options === null || options === void 0 ? void 0 : options.useBaseType) && ctx.schema.inheritedSchemas.some((x) => x.id === schema.id)) {
|
|
181
181
|
return ts.reference(this.getBaseTypeName(ctx, schema), this.getFilePath(ctx, schema), {
|
|
182
182
|
importType: 'type-import',
|
|
@@ -331,6 +331,10 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
331
331
|
if (!ctx.data.schemas.some((x) => x.id === schema.id)) {
|
|
332
332
|
return false;
|
|
333
333
|
}
|
|
334
|
+
// Check if "real" schema
|
|
335
|
+
if (getSchemaReference(ctx.schema, DEFAULT_IGNORED_SCHEMA_PROPERTIES) !== ctx.schema) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
334
338
|
// For all other types, check if the user has enabled inline unnamed schemas
|
|
335
339
|
return !ctx.config.inlineUnnamedSchemas;
|
|
336
340
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,2BAA2B;IACtB,QAAQ,CAAC,GAAG,EAAE,kCAAkC,GAAG,YAAY,CAAC,iCAAiC,CAAC;IAqBlH,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqErG,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IAuBjH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqBvE,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;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AE,QAAQ,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS;IAOnG,SAAS,CAAC,aAAa,CACrB,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,OAAO,CAAC,EAAE,uBAAuB,GAAG;QAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAAE,GAClE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAMnB,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAI5C,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI3E,SAAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIhF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIlF,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI5E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAU3C,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQxD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO;CAG3E"}
|
|
@@ -139,7 +139,8 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
139
139
|
const importOptions = ctx.config.language === 'javascript' ? { type: 'js-doc' } : {};
|
|
140
140
|
const description = `Parameters for operation ${this.getEndpointMethodName(ctx, endpoint)}`;
|
|
141
141
|
const typeName = this.getEndpointParamsTypeName(ctx, endpoint);
|
|
142
|
-
const properties = endpoint.parameters
|
|
142
|
+
const properties = endpoint.parameters
|
|
143
|
+
.map((parameter) => {
|
|
143
144
|
const schema = parameter.schema;
|
|
144
145
|
return {
|
|
145
146
|
name: toCasing(parameter.name, ctx.config.propertyNameCasing),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-beta.1",
|
|
4
4
|
"description": "Provides gOAst generators for generating TypeScript code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
|
-
"fs-extra": "^11.
|
|
28
|
-
"@goast/core": "0.
|
|
27
|
+
"fs-extra": "^11.3.3",
|
|
28
|
+
"@goast/core": "0.5.0-beta.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-builder.d.ts","sourceRoot":"","sources":["../../src/src/file-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-builder.d.ts","sourceRoot":"","sources":["../../src/src/file-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,iBAAiB,CAAC,kBAAkB,IAAI,MAAM,CAA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,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,yBAAyB,CAAC;QACpC,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACrD,GAAG,IAAI;WAIM,WAAW,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,yBAAyB,CAAC;QACpC,SAAS,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACrD;CASF"}
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeScriptFileBuilder = void 0;
|
|
4
4
|
exports.isTypeScriptAppendValue = isTypeScriptAppendValue;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
8
5
|
const core_1 = require("@goast/core");
|
|
9
6
|
const node_js_1 = require("./ast/node.js");
|
|
10
7
|
const config_js_1 = require("./config.js");
|
|
@@ -85,8 +82,7 @@ class TypeScriptFileBuilder extends core_1.SourceBuilder {
|
|
|
85
82
|
filePath = this.filePath;
|
|
86
83
|
if (!filePath)
|
|
87
84
|
throw new Error('File path is required');
|
|
88
|
-
|
|
89
|
-
fs_extra_1.default.writeFileSync(filePath, this.toString());
|
|
85
|
+
(0, core_1.writeGeneratedFile)(this.options, filePath, this.toString());
|
|
90
86
|
}
|
|
91
87
|
static generate(options) {
|
|
92
88
|
TypeScriptFileBuilder.tryGenerate(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,O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CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -179,7 +179,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
179
179
|
getType(ctx, schema, options) {
|
|
180
180
|
if (!schema)
|
|
181
181
|
return this.getAnyType(ctx);
|
|
182
|
-
schema = (0, core_1.getSchemaReference)(schema,
|
|
182
|
+
schema = (0, core_1.getSchemaReference)(schema, core_1.DEFAULT_IGNORED_SCHEMA_PROPERTIES);
|
|
183
183
|
if ((options === null || options === void 0 ? void 0 : options.useBaseType) && ctx.schema.inheritedSchemas.some((x) => x.id === schema.id)) {
|
|
184
184
|
return index_js_1.ts.reference(this.getBaseTypeName(ctx, schema), this.getFilePath(ctx, schema), {
|
|
185
185
|
importType: 'type-import',
|
|
@@ -334,6 +334,10 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
334
334
|
if (!ctx.data.schemas.some((x) => x.id === schema.id)) {
|
|
335
335
|
return false;
|
|
336
336
|
}
|
|
337
|
+
// Check if "real" schema
|
|
338
|
+
if ((0, core_1.getSchemaReference)(ctx.schema, core_1.DEFAULT_IGNORED_SCHEMA_PROPERTIES) !== ctx.schema) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
337
341
|
// For all other types, check if the user has enabled inline unnamed schemas
|
|
338
342
|
return !ctx.config.inlineUnnamedSchemas;
|
|
339
343
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AA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EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,2BAA2B;IACtB,QAAQ,CAAC,GAAG,EAAE,kCAAkC,GAAG,YAAY,CAAC,iCAAiC,CAAC;IAqBlH,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,C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S,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI3E,SAAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIhF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIlF,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI5E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAU3C,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQxD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO;CAG3E"}
|
|
@@ -142,7 +142,8 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
142
142
|
const importOptions = ctx.config.language === 'javascript' ? { type: 'js-doc' } : {};
|
|
143
143
|
const description = `Parameters for operation ${this.getEndpointMethodName(ctx, endpoint)}`;
|
|
144
144
|
const typeName = this.getEndpointParamsTypeName(ctx, endpoint);
|
|
145
|
-
const properties = endpoint.parameters
|
|
145
|
+
const properties = endpoint.parameters
|
|
146
|
+
.map((parameter) => {
|
|
146
147
|
const schema = parameter.schema;
|
|
147
148
|
return {
|
|
148
149
|
name: (0, core_1.toCasing)(parameter.name, ctx.config.propertyNameCasing),
|