-
Notifications
You must be signed in to change notification settings - Fork 507
/
testModel.ts
363 lines (324 loc) · 8.05 KB
/
testModel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/**
* This is a description of a model
* @tsoaModel
* @example
* {
* "boolArray": [true, false],
* "boolValue": true,
* "dateValue": "2018-06-25T15:45:00Z",
* "id": 2,
* "modelValue": {
* "id": 3,
* "email": "test(at)example.com"
* },
* "modelsArray": [],
* "numberArray": [1, 2, 3],
* "numberValue": 1,
* "optionalString": "optional string",
* "strLiteralArr": ["Foo", "Bar"],
* "strLiteralVal": "Foo",
* "stringArray": ["string one", "string two"],
* "stringValue": "a string"
* }
*/
export interface TestModel extends Model {
and: TypeAliasModel1 & TypeAliasModel2;
/**
* This is a description of this model property, numberValue
*/
numberValue: number;
numberArray: number[];
/**
* @format password
*/
stringValue: string;
stringArray: string[];
/**
* @default true
*/
boolValue: boolean;
boolArray: boolean[];
object: object;
objectArray: object[];
enumValue?: EnumIndexValue;
enumArray?: EnumIndexValue[];
enumNumberValue?: EnumNumberValue;
enumNumberArray?: EnumNumberValue[];
enumStringValue?: EnumStringValue;
enumStringArray?: EnumStringValue[];
modelValue: TestSubModel;
modelsArray: TestSubModel[];
strLiteralVal: StrLiteral;
strLiteralArr: StrLiteral[];
unionPrimetiveType?: 'String' | 1 | 20.0 | true | false;
dateValue?: Date;
optionalString?: string;
anyType?: any;
// modelsObjectDirect?: {[key: string]: TestSubModel2;};
modelsObjectIndirect?: TestSubModelContainer;
modelsObjectIndirectNS?: TestSubModelContainerNamespace.TestSubModelContainer;
modelsObjectIndirectNS2?: TestSubModelContainerNamespace.InnerNamespace.TestSubModelContainer2;
modelsObjectIndirectNS_Alias?: TestSubModelContainerNamespace_TestSubModelContainer;
modelsObjectIndirectNS2_Alias?: TestSubModelContainerNamespace_InnerNamespace_TestSubModelContainer2;
modelsArrayIndirect?: TestSubArrayModelContainer;
modelsEnumIndirect?: TestSubEnumModelContainer;
or: TypeAliasModel1 | TypeAliasModel2;
referenceAnd: TypeAliasModelCase1;
typeAliasCase1?: TypeAliasModelCase1;
TypeAliasCase2?: TypeAliasModelCase2;
genericMultiNested?: GenericRequest<GenericRequest<TypeAliasModel1>>;
// tslint:disable-next-line: array-type
genericNestedArrayKeyword1?: GenericRequest<Array<TypeAliasModel1>>;
genericNestedArrayCharacter1?: GenericRequest<TypeAliasModel1[]>;
// tslint:disable-next-line: array-type
genericNestedArrayKeyword2?: GenericRequest<Array<TypeAliasModel2>>;
genericNestedArrayCharacter2?: GenericRequest<TypeAliasModel2[]>;
mixedUnion?: string | TypeAliasModel1;
}
export interface TypeAliasModel1 {
value1: string;
}
export interface TypeAliasModel2 {
value2: string;
}
export class TypeAliasModel3 {
public value3: string;
}
export type TypeAliasModelCase1 = TypeAliasModel1 & TypeAliasModel2;
export type TypeAliasModelCase2 = TypeAliasModelCase1 & TypeAliasModel3;
/**
* EnumIndexValue.
*/
export enum EnumIndexValue {
VALUE_1,
VALUE_2,
}
/**
* EnumNumberValue.
*/
export enum EnumNumberValue {
VALUE_1 = 2,
VALUE_2 = 5,
}
/**
* EnumStringValue.
*/
export enum EnumStringValue {
VALUE_1 = 'VALUE_1' as any,
VALUE_2 = 'VALUE_2' as any,
}
// shortened from StringLiteral to make the tslint enforced
// alphabetical sorting cleaner
export type StrLiteral = 'Foo' | 'Bar';
export interface TestSubModelContainer {
[key: string]: TestSubModel2;
}
export interface TestSubArrayModelContainer {
[key: string]: TestSubModel2[];
}
export interface TestSubEnumModelContainer {
[key: string]: EnumStringValue;
}
export namespace TestSubModelContainerNamespace {
export interface TestSubModelContainer {
[key: string]: TestSubModelNamespace.TestSubModelNS;
}
export namespace InnerNamespace {
export interface TestSubModelContainer2 {
[key: string]: TestSubModelNamespace.TestSubModelNS;
}
}
}
export type TestSubModelContainerNamespace_TestSubModelContainer = TestSubModelContainerNamespace.TestSubModelContainer;
export type TestSubModelContainerNamespace_InnerNamespace_TestSubModelContainer2 = TestSubModelContainerNamespace.InnerNamespace.TestSubModelContainer2;
export interface TestSubModel extends Model {
email: string;
circular?: TestModel;
}
export interface TestSubModel2 extends TestSubModel {
testSubModel2: boolean;
}
export namespace TestSubModelNamespace {
export interface TestSubModelNS extends TestSubModel {
testSubModelNS: boolean;
}
}
export interface BooleanResponseModel {
success: boolean;
}
export interface UserResponseModel {
id: number;
name: string;
}
export class ParameterTestModel {
public firstname: string;
public lastname: string;
/**
* @isInt
* @minimum 1
* @maximum 100
*/
public age: number;
/**
* @isFloat
*/
public weight: number;
public human: boolean;
public gender: Gender;
public nicknames?: string[];
}
export class ValidateCustomErrorModel {}
export class ValidateModel {
/**
* @isFloat Invalid float error message.
*/
public floatValue: number;
/**
* @isDouble Invalid double error message.
*/
public doubleValue: number;
/**
* @isInt invalid integer number
*/
public intValue: number;
/**
* @isLong Custom Required long number.
*/
public longValue: number;
/**
* @isBoolean
*/
public booleanValue: boolean;
/**
* @isArray
*/
public arrayValue: number[];
/**
* @isDate invalid ISO 8601 date format, i.e. YYYY-MM-DD
*/
public dateValue: Date;
/**
* @isDateTime
*/
public datetimeValue: Date;
/**
* @maximum 10
*/
public numberMax10: number;
/**
* @minimum 5
*/
public numberMin5: number;
/**
* @maxLength 10
*/
public stringMax10Lenght: string;
/**
* @minLength 5
*/
public stringMin5Lenght: string;
/**
* @pattern ^[a-zA-Z]+$
*/
public stringPatternAZaz: string;
/**
* @maxItems 5
*/
public arrayMax5Item: number[];
/**
* @minItems 2
*/
public arrayMin2Item: number[];
/**
* @uniqueItems
*/
public arrayUniqueItem: number[];
/**
* @ignore
*/
public ignoredProperty: string;
public model: TypeAliasModel1;
public intersection?: TypeAliasModel1 & TypeAliasModel2;
public intersectionNoAdditional?: TypeAliasModel1 & TypeAliasModel2;
public mixedUnion?: string | TypeAliasModel1;
}
export interface ValidateMapStringToNumber {
[key: string]: number;
}
export interface ValidateMapStringToAny {
[key: string]: any;
}
/**
* Gender msg
*/
export enum Gender {
MALE = 'MALE' as any,
FEMALE = 'FEMALE' as any,
}
export interface ErrorResponseModel {
status: number;
message: string;
}
export interface Model {
id: number;
}
export class TestClassBaseModel {
public id: number;
public defaultValue1 = 'Default Value 1';
}
// bug #158
export class Account {
public id: number;
}
/**
* This is a description of TestClassModel
*/
export class TestClassModel extends TestClassBaseModel {
public account: Account;
public defaultValue2 = 'Default Value 2';
/**
* This is a description of a public string property
*
* @minLength 3
* @maxLength 20
* @pattern ^[a-zA-Z]+$
*/
public publicStringProperty: string;
/**
* @minLength 0
* @maxLength 10
*/
public optionalPublicStringProperty?: string;
/**
* @format email
* @pattern ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$
*/
public emailPattern?: string;
/* tslint:disable-next-line */
stringProperty: string;
protected protectedStringProperty: string;
public static typeLiterals = {
booleanTypeLiteral: { $type: Boolean },
numberTypeLiteral: { $type: Number },
stringTypeLiteral: { $type: String },
};
/**
* @param publicConstructorVar This is a description for publicConstructorVar
*/
constructor(
public publicConstructorVar: string,
protected protectedConstructorVar: string,
defaultConstructorArgument: string,
readonly readonlyConstructorArgument: string,
public optionalPublicConstructorVar?: string,
) {
super();
}
}
export interface GenericModel<T> {
result: T;
}
export interface GenericRequest<T> {
name: string;
value: T;
}