@team-supercharge/oasg 16.4.0-feature-aspdotnetcore-generator-d9a217c3.0 → 16.4.0-feature-aspdotnetcore-generator-72786d96.0
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@team-supercharge/oasg",
|
3
|
-
"version": "16.4.0-feature-aspdotnetcore-generator-
|
3
|
+
"version": "16.4.0-feature-aspdotnetcore-generator-72786d96.0",
|
4
4
|
"description": "Node-based tool to lint OpenAPI documents and generate clients, servers and documentation from them",
|
5
5
|
"author": "Supercharge",
|
6
6
|
"license": "MIT",
|
@@ -0,0 +1,198 @@
|
|
1
|
+
{{>partial_header}}
|
2
|
+
using System;
|
3
|
+
using System.Linq;
|
4
|
+
using System.Text;
|
5
|
+
using System.Collections.Generic;
|
6
|
+
using System.ComponentModel;
|
7
|
+
using System.ComponentModel.DataAnnotations;
|
8
|
+
using System.Runtime.Serialization;
|
9
|
+
{{#useNewtonsoft}}
|
10
|
+
using Newtonsoft.Json;
|
11
|
+
{{/useNewtonsoft}}
|
12
|
+
{{^useNewtonsoft}}
|
13
|
+
using System.Text.Json;
|
14
|
+
{{/useNewtonsoft}}
|
15
|
+
{{#models}}
|
16
|
+
{{#model}}
|
17
|
+
{{#discriminator}}
|
18
|
+
using JsonSubTypes;
|
19
|
+
{{#useSwashbuckle}}
|
20
|
+
using Swashbuckle.AspNetCore.Annotations;
|
21
|
+
{{/useSwashbuckle}}
|
22
|
+
{{/discriminator}}
|
23
|
+
{{/model}}
|
24
|
+
{{/models}}
|
25
|
+
using {{packageName}}.Converters;
|
26
|
+
|
27
|
+
{{#models}}
|
28
|
+
{{#model}}
|
29
|
+
namespace {{modelPackage}}
|
30
|
+
{ {{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
|
31
|
+
/// <summary>
|
32
|
+
/// {{description}}
|
33
|
+
/// </summary>
|
34
|
+
[DataContract]
|
35
|
+
{{#discriminator}}
|
36
|
+
{{#useNewtonsoft}}
|
37
|
+
{{#mappedModels.size}}
|
38
|
+
[JsonConverter(typeof(JsonSubtypes), "{{{discriminatorName}}}")]
|
39
|
+
{{/mappedModels.size}}
|
40
|
+
{{/useNewtonsoft}}
|
41
|
+
{{#useSwashbuckle}}
|
42
|
+
[SwaggerDiscriminator("{{{discriminatorName}}}")]
|
43
|
+
{{/useSwashbuckle}}
|
44
|
+
{{#mappedModels}}
|
45
|
+
[JsonSubtypes.KnownSubType(typeof({{{modelName}}}), "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
46
|
+
{{#useSwashbuckle}}
|
47
|
+
[SwaggerSubType(typeof({{{modelName}}}), DiscriminatorValue = "{{^vendorExtensions.x-discriminator-value}}{{{mappingName}}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{.}}}{{/vendorExtensions.x-discriminator-value}}")]
|
48
|
+
{{/useSwashbuckle}}
|
49
|
+
{{/mappedModels}}
|
50
|
+
{{/discriminator}}
|
51
|
+
public {{#modelClassModifier}}{{.}} {{/modelClassModifier}}class {{classname}} {{#parent}}: {{{.}}}{{^pocoModels}}, {{/pocoModels}}{{/parent}}{{^pocoModels}}{{^parent}}: {{/parent}}IEquatable<{{classname}}>{{/pocoModels}}
|
52
|
+
{
|
53
|
+
{{#vars}}
|
54
|
+
{{#items.isEnum}}
|
55
|
+
{{#items}}
|
56
|
+
{{^complexType}}
|
57
|
+
{{>enumClass}}
|
58
|
+
{{/complexType}}
|
59
|
+
{{/items}}
|
60
|
+
{{/items.isEnum}}
|
61
|
+
{{#isEnum}}
|
62
|
+
{{^complexType}}
|
63
|
+
{{>enumClass}}
|
64
|
+
{{/complexType}}
|
65
|
+
{{/isEnum}}
|
66
|
+
/// <summary>
|
67
|
+
/// {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}}
|
68
|
+
/// </summary>{{#description}}
|
69
|
+
/// <value>{{.}}</value>{{/description}}{{#example}}
|
70
|
+
/* <example>{{.}}</example> */{{/example}}{{#required}}
|
71
|
+
[Required]{{/required}}{{#pattern}}
|
72
|
+
[RegularExpression("{{{.}}}")]{{/pattern}}{{#minLength}}{{#maxLength}}
|
73
|
+
[StringLength({{maxLength}}, MinimumLength={{minLength}})]{{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}}
|
74
|
+
[MinLength({{minLength}})]{{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}}
|
75
|
+
[MaxLength({{.}})]{{/maxLength}}{{/minLength}}{{#minimum}}{{#maximum}}
|
76
|
+
[Range({{minimum}}, {{maximum}})]{{/maximum}}{{/minimum}}
|
77
|
+
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{#vendorExtensions.x-is-value-type}}true{{/vendorExtensions.x-is-value-type}}{{^vendorExtensions.x-is-value-type}}false{{/vendorExtensions.x-is-value-type}}{{/isNullable}})]
|
78
|
+
{{#isEnum}}
|
79
|
+
public {{{datatypeWithEnum}}}{{#isNullable}}{{^required}}?{{/required}}{{/isNullable}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
80
|
+
{{/isEnum}}
|
81
|
+
{{^isEnum}}
|
82
|
+
public {{{dataType}}}{{#nullableReferenceTypes}}{{^isContainer}}{{^required}}{{^isNullable}}?{{/isNullable}}{{/required}}{{/isContainer}}{{/nullableReferenceTypes}} {{name}} { get; set; }{{#defaultValue}} = {{{.}}};{{/defaultValue}}
|
83
|
+
{{/isEnum}}
|
84
|
+
{{^-last}}
|
85
|
+
|
86
|
+
{{/-last}}
|
87
|
+
{{/vars}}
|
88
|
+
|
89
|
+
{{^pocoModels}}
|
90
|
+
/// <summary>
|
91
|
+
/// Returns the string presentation of the object
|
92
|
+
/// </summary>
|
93
|
+
/// <returns>String presentation of the object</returns>
|
94
|
+
public override string ToString()
|
95
|
+
{
|
96
|
+
var sb = new StringBuilder();
|
97
|
+
sb.Append("class {{classname}} {\n");
|
98
|
+
{{#vars}}
|
99
|
+
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
100
|
+
{{/vars}}
|
101
|
+
sb.Append("}\n");
|
102
|
+
return sb.ToString();
|
103
|
+
}
|
104
|
+
|
105
|
+
/// <summary>
|
106
|
+
/// Returns the JSON string presentation of the object
|
107
|
+
/// </summary>
|
108
|
+
/// <returns>JSON string presentation of the object</returns>
|
109
|
+
public {{#parent}}{{^isMap}}{{^isArray}}new {{/isArray}}{{/isMap}}{{/parent}}string ToJson()
|
110
|
+
{
|
111
|
+
{{#useNewtonsoft}}
|
112
|
+
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
113
|
+
{{/useNewtonsoft}}
|
114
|
+
{{^useNewtonsoft}}
|
115
|
+
var options = new JsonSerializerOptions
|
116
|
+
{
|
117
|
+
WriteIndented = true
|
118
|
+
};
|
119
|
+
|
120
|
+
return JsonSerializer.Serialize(this, options);
|
121
|
+
{{/useNewtonsoft}}
|
122
|
+
}
|
123
|
+
|
124
|
+
/// <summary>
|
125
|
+
/// Returns true if objects are equal
|
126
|
+
/// </summary>
|
127
|
+
/// <param name="obj">Object to be compared</param>
|
128
|
+
/// <returns>Boolean</returns>
|
129
|
+
public override bool Equals(object obj)
|
130
|
+
{
|
131
|
+
if (obj is null) return false;
|
132
|
+
if (ReferenceEquals(this, obj)) return true;
|
133
|
+
return obj.GetType() == GetType() && Equals(({{classname}})obj);
|
134
|
+
}
|
135
|
+
|
136
|
+
/// <summary>
|
137
|
+
/// Returns true if {{classname}} instances are equal
|
138
|
+
/// </summary>
|
139
|
+
/// <param name="other">Instance of {{classname}} to be compared</param>
|
140
|
+
/// <returns>Boolean</returns>
|
141
|
+
public bool Equals({{classname}} other)
|
142
|
+
{
|
143
|
+
if (other is null) return false;
|
144
|
+
if (ReferenceEquals(this, other)) return true;
|
145
|
+
|
146
|
+
return {{#vars}}{{^isContainer}}
|
147
|
+
(
|
148
|
+
{{name}} == other.{{name}} ||
|
149
|
+
{{^vendorExtensions.x-is-value-type}}{{name}} != null &&{{/vendorExtensions.x-is-value-type}}
|
150
|
+
{{name}}.Equals(other.{{name}})
|
151
|
+
){{^-last}} && {{/-last}}{{/isContainer}}{{#isContainer}}
|
152
|
+
(
|
153
|
+
{{name}} == other.{{name}} ||
|
154
|
+
{{^vendorExtensions.x-is-value-type}}{{name}} != null &&
|
155
|
+
other.{{name}} != null &&
|
156
|
+
{{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(other.{{name}})
|
157
|
+
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
|
158
|
+
}
|
159
|
+
|
160
|
+
/// <summary>
|
161
|
+
/// Gets the hash code
|
162
|
+
/// </summary>
|
163
|
+
/// <returns>Hash code</returns>
|
164
|
+
public override int GetHashCode()
|
165
|
+
{
|
166
|
+
unchecked // Overflow is fine, just wrap
|
167
|
+
{
|
168
|
+
var hashCode = 41;
|
169
|
+
// Suitable nullity checks etc, of course :)
|
170
|
+
{{#vars}}
|
171
|
+
{{^vendorExtensions.x-is-value-type}}if ({{name}} != null){{/vendorExtensions.x-is-value-type}}
|
172
|
+
hashCode = hashCode * 59 + {{name}}.GetHashCode();
|
173
|
+
{{/vars}}
|
174
|
+
return hashCode;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
#region Operators
|
179
|
+
#pragma warning disable 1591
|
180
|
+
|
181
|
+
public static bool operator ==({{classname}} left, {{classname}} right)
|
182
|
+
{
|
183
|
+
return Equals(left, right);
|
184
|
+
}
|
185
|
+
|
186
|
+
public static bool operator !=({{classname}} left, {{classname}} right)
|
187
|
+
{
|
188
|
+
return !Equals(left, right);
|
189
|
+
}
|
190
|
+
|
191
|
+
#pragma warning restore 1591
|
192
|
+
#endregion Operators
|
193
|
+
{{/pocoModels}}
|
194
|
+
}
|
195
|
+
{{/isEnum}}
|
196
|
+
{{/model}}
|
197
|
+
{{/models}}
|
198
|
+
}
|