@@ -4,6 +4,7 @@ namespace LEGO.AsyncAPI.Models
44{
55 using System ;
66 using System . Collections . Generic ;
7+ using System . Linq ;
78 using LEGO . AsyncAPI . Models . Interfaces ;
89 using LEGO . AsyncAPI . Writers ;
910
@@ -18,13 +19,12 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
1819 public string Title { get ; set ; }
1920
2021 /// <summary>
21- /// follow JSON Schema definition: https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
22- /// Value MUST be a string. Multiple types via an array are not supported.
22+ /// follow JSON Schema definition: https://json-schema.org/draft-07/json-schema-release-notes.html
2323 /// </summary>
24- public string Type { get ; set ; }
24+ public IList < SchemaType > Type { get ; set ; }
2525
2626 /// <summary>
27- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
27+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
2828 /// </summary>
2929 public string Format { get ; set ; }
3030
@@ -35,43 +35,43 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
3535 public string Description { get ; set ; }
3636
3737 /// <summary>
38- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
38+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
3939 /// </summary>
4040 public decimal ? Maximum { get ; set ; }
4141
4242 /// <summary>
43- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
43+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
4444 /// </summary>
4545 public bool ? ExclusiveMaximum { get ; set ; }
4646
4747 /// <summary>
48- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
48+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
4949 /// </summary>
5050 public decimal ? Minimum { get ; set ; }
5151
5252 /// <summary>
53- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
53+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
5454 /// </summary>
5555 public bool ? ExclusiveMinimum { get ; set ; }
5656
5757 /// <summary>
58- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
58+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
5959 /// </summary>
6060 public int ? MaxLength { get ; set ; }
6161
6262 /// <summary>
63- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
63+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
6464 /// </summary>
6565 public int ? MinLength { get ; set ; }
6666
6767 /// <summary>
68- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
68+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
6969 /// This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect.
7070 /// </summary>
7171 public string Pattern { get ; set ; }
7272
7373 /// <summary>
74- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
74+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
7575 /// </summary>
7676 public decimal ? MultipleOf { get ; set ; }
7777
@@ -104,101 +104,101 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
104104 public bool WriteOnly { get ; set ; }
105105
106106 /// <summary>
107- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
107+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
108108 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
109109 /// </summary>
110110 public IList < AsyncApiSchema > AllOf { get ; set ; } = new List < AsyncApiSchema > ( ) ;
111111
112112 /// <summary>
113- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
113+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
114114 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
115115 /// </summary>
116116 public IList < AsyncApiSchema > OneOf { get ; set ; } = new List < AsyncApiSchema > ( ) ;
117117
118118 /// <summary>
119- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
119+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
120120 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
121121 /// </summary>
122122 public IList < AsyncApiSchema > AnyOf { get ; set ; } = new List < AsyncApiSchema > ( ) ;
123123
124124 /// <summary>
125- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
125+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
126126 /// Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
127127 /// </summary>
128128 public AsyncApiSchema Not { get ; set ; }
129129
130130 /// <summary>
131- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
131+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
132132 /// </summary>
133133 public AsyncApiSchema Contains { get ; set ; }
134134
135135 /// <summary>
136- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
136+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
137137 /// </summary>
138138 public AsyncApiSchema If { get ; set ; }
139139
140140 /// <summary>
141- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
141+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
142142 /// </summary>
143143 public AsyncApiSchema Then { get ; set ; }
144144
145145 /// <summary>
146- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
146+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
147147 /// </summary>
148148 public AsyncApiSchema Else { get ; set ; }
149149
150150 /// <summary>
151- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
151+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
152152 /// </summary>
153153 public ISet < string > Required { get ; set ; } = new HashSet < string > ( ) ;
154154
155155 /// <summary>
156- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
156+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
157157 /// Value MUST be an object and not an array. Inline or referenced schema MUST be of a Schema Object
158158 /// and not a standard JSON Schema. items MUST be present if the type is array.
159159 /// </summary>
160160 public AsyncApiSchema Items { get ; set ; }
161161
162162 /// <summary>
163- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
163+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
164164 /// </summary>
165165 public int ? MaxItems { get ; set ; }
166166
167167 /// <summary>
168- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
168+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
169169 /// </summary>
170170 public int ? MinItems { get ; set ; }
171171
172172 /// <summary>
173- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
173+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
174174 /// </summary>
175175 public bool ? UniqueItems { get ; set ; }
176176
177177 /// <summary>
178- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
178+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
179179 /// Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced).
180180 /// </summary>
181181 public IDictionary < string , AsyncApiSchema > Properties { get ; set ; } = new Dictionary < string , AsyncApiSchema > ( ) ;
182182
183183 /// <summary>
184- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
184+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
185185 /// </summary>
186186 public int ? MaxProperties { get ; set ; }
187187
188188 /// <summary>
189- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
189+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
190190 /// </summary>
191191 public int ? MinProperties { get ; set ; }
192192
193193 /// <summary>
194- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01
194+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html
195195 /// Value can be boolean or object. Inline or referenced schema
196196 /// MUST be of a Schema Object and not a standard JSON Schema.
197197 /// </summary>
198198 public AsyncApiSchema AdditionalProperties { get ; set ; }
199199
200200 /// <summary>
201- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
201+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
202202 /// </summary>
203203 public AsyncApiSchema PropertyNames { get ; set ; }
204204
@@ -209,17 +209,17 @@ public class AsyncApiSchema : IAsyncApiReferenceable, IAsyncApiExtensible, IAsyn
209209 public string Discriminator { get ; set ; }
210210
211211 /// <summary>
212- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
212+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
213213 /// </summary>
214214 public IList < IAsyncApiAny > Enum { get ; set ; } = new List < IAsyncApiAny > ( ) ;
215215
216216 /// <summary>
217- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
217+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
218218 /// </summary>
219219 public IList < IAsyncApiAny > Examples { get ; set ; } = new List < IAsyncApiAny > ( ) ;
220220
221221 /// <summary>
222- /// follow JSON Schema definition: https://tools.ietf. org/html/ draft-handrews- json-schema-validation-01 .
222+ /// follow JSON Schema definition: https://json-schema. org/draft-07/ json-schema-release-notes.html .
223223 /// </summary>
224224 public IAsyncApiAny Const { get ; set ; }
225225
@@ -302,7 +302,17 @@ public void SerializeV2WithoutReference(IAsyncApiWriter writer)
302302 writer . WriteOptionalObject ( AsyncApiConstants . Const , this . Const , ( w , s ) => w . WriteAny ( s ) ) ;
303303
304304 // type
305- writer . WriteProperty ( AsyncApiConstants . Type , this . Type ) ;
305+ if ( this . Type != null )
306+ {
307+ if ( this . Type . Count == 1 )
308+ {
309+ writer . WriteProperty ( AsyncApiConstants . Type , this . Type . First ( ) . GetDisplayName ( ) ) ;
310+ }
311+ else
312+ {
313+ writer . WriteOptionalCollection ( AsyncApiConstants . Type , this . Type . Select ( t => t . GetDisplayName ( ) ) , ( w , s ) => w . WriteValue ( s ) ) ;
314+ }
315+ }
306316
307317 // allOf
308318 writer . WriteOptionalCollection ( AsyncApiConstants . AllOf , this . AllOf , ( w , s ) => s . SerializeV2 ( w ) ) ;
0 commit comments