forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormatTest.cs
375 lines (334 loc) · 14.8 KB
/
FormatTest.cs
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
364
365
366
367
368
369
370
371
372
373
374
375
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*/
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
namespace Org.OpenAPITools.Model
{
/// <summary>
/// FormatTest
/// </summary>
[DataContract]
public partial class FormatTest : IEquatable<FormatTest>, IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="FormatTest" /> class.
/// </summary>
[JsonConstructorAttribute]
protected FormatTest() { }
/// <summary>
/// Initializes a new instance of the <see cref="FormatTest" /> class.
/// </summary>
/// <param name="integer">integer.</param>
/// <param name="int32">int32.</param>
/// <param name="int64">int64.</param>
/// <param name="number">number (required).</param>
/// <param name="_float">_float.</param>
/// <param name="_double">_double.</param>
/// <param name="_string">_string.</param>
/// <param name="_byte">_byte (required).</param>
/// <param name="binary">binary.</param>
/// <param name="date">date (required).</param>
/// <param name="dateTime">dateTime.</param>
/// <param name="uuid">uuid.</param>
/// <param name="password">password (required).</param>
/// <param name="bigDecimal">bigDecimal.</param>
public FormatTest(int integer = default(int), int int32 = default(int), long int64 = default(long), decimal number = default(decimal), float _float = default(float), double _double = default(double), string _string = default(string), byte[] _byte = default(byte[]), System.IO.Stream binary = default(System.IO.Stream), DateTime date = default(DateTime), DateTime dateTime = default(DateTime), Guid uuid = default(Guid), string password = default(string), decimal bigDecimal = default(decimal))
{
// to ensure "number" is required (not null)
if (number == null)
{
throw new InvalidDataException("number is a required property for FormatTest and cannot be null");
}
else
{
this.Number = number;
}
// to ensure "_byte" is required (not null)
if (_byte == null)
{
throw new InvalidDataException("_byte is a required property for FormatTest and cannot be null");
}
else
{
this.Byte = _byte;
}
// to ensure "date" is required (not null)
if (date == null)
{
throw new InvalidDataException("date is a required property for FormatTest and cannot be null");
}
else
{
this.Date = date;
}
// to ensure "password" is required (not null)
if (password == null)
{
throw new InvalidDataException("password is a required property for FormatTest and cannot be null");
}
else
{
this.Password = password;
}
this.Integer = integer;
this.Int32 = int32;
this.Int64 = int64;
this.Float = _float;
this.Double = _double;
this.String = _string;
this.Binary = binary;
this.DateTime = dateTime;
this.Uuid = uuid;
this.BigDecimal = bigDecimal;
}
/// <summary>
/// Gets or Sets Integer
/// </summary>
[DataMember(Name="integer", EmitDefaultValue=false)]
public int Integer { get; set; }
/// <summary>
/// Gets or Sets Int32
/// </summary>
[DataMember(Name="int32", EmitDefaultValue=false)]
public int Int32 { get; set; }
/// <summary>
/// Gets or Sets Int64
/// </summary>
[DataMember(Name="int64", EmitDefaultValue=false)]
public long Int64 { get; set; }
/// <summary>
/// Gets or Sets Number
/// </summary>
[DataMember(Name="number", EmitDefaultValue=false)]
public decimal Number { get; set; }
/// <summary>
/// Gets or Sets Float
/// </summary>
[DataMember(Name="float", EmitDefaultValue=false)]
public float Float { get; set; }
/// <summary>
/// Gets or Sets Double
/// </summary>
[DataMember(Name="double", EmitDefaultValue=false)]
public double Double { get; set; }
/// <summary>
/// Gets or Sets String
/// </summary>
[DataMember(Name="string", EmitDefaultValue=false)]
public string String { get; set; }
/// <summary>
/// Gets or Sets Byte
/// </summary>
[DataMember(Name="byte", EmitDefaultValue=false)]
public byte[] Byte { get; set; }
/// <summary>
/// Gets or Sets Binary
/// </summary>
[DataMember(Name="binary", EmitDefaultValue=false)]
public System.IO.Stream Binary { get; set; }
/// <summary>
/// Gets or Sets Date
/// </summary>
[DataMember(Name="date", EmitDefaultValue=false)]
[JsonConverter(typeof(OpenAPIDateConverter))]
public DateTime Date { get; set; }
/// <summary>
/// Gets or Sets DateTime
/// </summary>
[DataMember(Name="dateTime", EmitDefaultValue=false)]
public DateTime DateTime { get; set; }
/// <summary>
/// Gets or Sets Uuid
/// </summary>
[DataMember(Name="uuid", EmitDefaultValue=false)]
public Guid Uuid { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
[DataMember(Name="password", EmitDefaultValue=false)]
public string Password { get; set; }
/// <summary>
/// Gets or Sets BigDecimal
/// </summary>
[DataMember(Name="BigDecimal", EmitDefaultValue=false)]
public decimal BigDecimal { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class FormatTest {\n");
sb.Append(" Integer: ").Append(Integer).Append("\n");
sb.Append(" Int32: ").Append(Int32).Append("\n");
sb.Append(" Int64: ").Append(Int64).Append("\n");
sb.Append(" Number: ").Append(Number).Append("\n");
sb.Append(" Float: ").Append(Float).Append("\n");
sb.Append(" Double: ").Append(Double).Append("\n");
sb.Append(" String: ").Append(String).Append("\n");
sb.Append(" Byte: ").Append(Byte).Append("\n");
sb.Append(" Binary: ").Append(Binary).Append("\n");
sb.Append(" Date: ").Append(Date).Append("\n");
sb.Append(" DateTime: ").Append(DateTime).Append("\n");
sb.Append(" Uuid: ").Append(Uuid).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" BigDecimal: ").Append(BigDecimal).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="input">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input as FormatTest).AreEqual;
}
/// <summary>
/// Returns true if FormatTest instances are equal
/// </summary>
/// <param name="input">Instance of FormatTest to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(FormatTest input)
{
return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
hashCode = hashCode * 59 + this.Integer.GetHashCode();
hashCode = hashCode * 59 + this.Int32.GetHashCode();
hashCode = hashCode * 59 + this.Int64.GetHashCode();
hashCode = hashCode * 59 + this.Number.GetHashCode();
hashCode = hashCode * 59 + this.Float.GetHashCode();
hashCode = hashCode * 59 + this.Double.GetHashCode();
if (this.String != null)
hashCode = hashCode * 59 + this.String.GetHashCode();
if (this.Byte != null)
hashCode = hashCode * 59 + this.Byte.GetHashCode();
if (this.Binary != null)
hashCode = hashCode * 59 + this.Binary.GetHashCode();
if (this.Date != null)
hashCode = hashCode * 59 + this.Date.GetHashCode();
if (this.DateTime != null)
hashCode = hashCode * 59 + this.DateTime.GetHashCode();
if (this.Uuid != null)
hashCode = hashCode * 59 + this.Uuid.GetHashCode();
if (this.Password != null)
hashCode = hashCode * 59 + this.Password.GetHashCode();
hashCode = hashCode * 59 + this.BigDecimal.GetHashCode();
return hashCode;
}
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
// Integer (int) maximum
if(this.Integer > (int)100)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value less than or equal to 100.", new [] { "Integer" });
}
// Integer (int) minimum
if(this.Integer < (int)10)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Integer, must be a value greater than or equal to 10.", new [] { "Integer" });
}
// Int32 (int) maximum
if(this.Int32 > (int)200)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value less than or equal to 200.", new [] { "Int32" });
}
// Int32 (int) minimum
if(this.Int32 < (int)20)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Int32, must be a value greater than or equal to 20.", new [] { "Int32" });
}
// Number (decimal) maximum
if(this.Number > (decimal)543.2)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value less than or equal to 543.2.", new [] { "Number" });
}
// Number (decimal) minimum
if(this.Number < (decimal)32.1)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Number, must be a value greater than or equal to 32.1.", new [] { "Number" });
}
// Float (float) maximum
if(this.Float > (float)987.6)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value less than or equal to 987.6.", new [] { "Float" });
}
// Float (float) minimum
if(this.Float < (float)54.3)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Float, must be a value greater than or equal to 54.3.", new [] { "Float" });
}
// Double (double) maximum
if(this.Double > (double)123.4)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value less than or equal to 123.4.", new [] { "Double" });
}
// Double (double) minimum
if(this.Double < (double)67.8)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Double, must be a value greater than or equal to 67.8.", new [] { "Double" });
}
// String (string) pattern
Regex regexString = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
if (false == regexString.Match(this.String).Success)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for String, must match a pattern of " + regexString, new [] { "String" });
}
// Password (string) maxLength
if(this.Password != null && this.Password.Length > 64)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be less than 64.", new [] { "Password" });
}
// Password (string) minLength
if(this.Password != null && this.Password.Length < 10)
{
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Password, length must be greater than 10.", new [] { "Password" });
}
yield break;
}
}
}