@@ -8,7 +8,7 @@ namespace OpenApiTests.ModelStateValidation;
8
8
public sealed class ModelStateValidationTests : IClassFixture < OpenApiTestContext < OpenApiStartup < ModelStateValidationDbContext > , ModelStateValidationDbContext > >
9
9
{
10
10
// ReSharper disable once UseCollectionExpression (https://youtrack.jetbrains.com/issue/RSRP-497450)
11
- public static readonly TheoryData < string > ModelNames = new ( )
11
+ public static readonly TheoryData < string > SchemaNames = new ( )
12
12
{
13
13
"socialMediaAccountAttributesInPostRequest" ,
14
14
"socialMediaAccountAttributesInPatchRequest" ,
@@ -34,7 +34,7 @@ public ModelStateValidationTests(OpenApiTestContext<OpenApiStartup<ModelStateVal
34
34
}
35
35
36
36
[ Theory ]
37
- [ MemberData ( nameof ( ModelNames ) ) ]
37
+ [ MemberData ( nameof ( SchemaNames ) ) ]
38
38
public async Task Guid_type_produces_expected_schema ( string modelName )
39
39
{
40
40
// Act
@@ -49,7 +49,7 @@ public async Task Guid_type_produces_expected_schema(string modelName)
49
49
}
50
50
51
51
[ Theory ]
52
- [ MemberData ( nameof ( ModelNames ) ) ]
52
+ [ MemberData ( nameof ( SchemaNames ) ) ]
53
53
public async Task Length_annotation_on_resource_string_property_produces_expected_schema ( string modelName )
54
54
{
55
55
// Act
@@ -67,7 +67,7 @@ public async Task Length_annotation_on_resource_string_property_produces_expecte
67
67
}
68
68
69
69
[ Theory ]
70
- [ MemberData ( nameof ( ModelNames ) ) ]
70
+ [ MemberData ( nameof ( SchemaNames ) ) ]
71
71
public async Task Required_annotation_with_AllowEmptyStrings_on_resource_property_produces_expected_schema ( string modelName )
72
72
{
73
73
// Act
@@ -82,7 +82,7 @@ public async Task Required_annotation_with_AllowEmptyStrings_on_resource_propert
82
82
}
83
83
84
84
[ Theory ]
85
- [ MemberData ( nameof ( ModelNames ) ) ]
85
+ [ MemberData ( nameof ( SchemaNames ) ) ]
86
86
public async Task StringLength_annotation_on_resource_property_produces_expected_schema ( string modelName )
87
87
{
88
88
// Act
@@ -98,7 +98,7 @@ public async Task StringLength_annotation_on_resource_property_produces_expected
98
98
}
99
99
100
100
[ Theory ]
101
- [ MemberData ( nameof ( ModelNames ) ) ]
101
+ [ MemberData ( nameof ( SchemaNames ) ) ]
102
102
public async Task RegularExpression_annotation_on_resource_property_produces_expected_schema ( string modelName )
103
103
{
104
104
// Act
@@ -113,7 +113,7 @@ public async Task RegularExpression_annotation_on_resource_property_produces_exp
113
113
}
114
114
115
115
[ Theory ]
116
- [ MemberData ( nameof ( ModelNames ) ) ]
116
+ [ MemberData ( nameof ( SchemaNames ) ) ]
117
117
public async Task CreditCard_annotation_on_resource_property_produces_expected_schema ( string modelName )
118
118
{
119
119
// Act
@@ -128,7 +128,7 @@ public async Task CreditCard_annotation_on_resource_property_produces_expected_s
128
128
}
129
129
130
130
[ Theory ]
131
- [ MemberData ( nameof ( ModelNames ) ) ]
131
+ [ MemberData ( nameof ( SchemaNames ) ) ]
132
132
public async Task Email_annotation_on_resource_property_produces_expected_schema ( string modelName )
133
133
{
134
134
// Act
@@ -143,21 +143,25 @@ public async Task Email_annotation_on_resource_property_produces_expected_schema
143
143
}
144
144
145
145
[ Theory ]
146
- [ MemberData ( nameof ( ModelNames ) ) ]
147
- public async Task Base64String_annotation_on_resource_property_produces_expected_schema ( string modelName )
146
+ [ MemberData ( nameof ( SchemaNames ) ) ]
147
+ public async Task Min_max_length_annotation_on_resource_list_property_produces_expected_schema ( string modelName )
148
148
{
149
149
// Act
150
150
JsonElement document = await _testContext . GetSwaggerDocumentAsync ( ) ;
151
151
152
152
// Assert
153
153
document . Should ( ) . ContainPath ( $ "components.schemas.{ modelName } .properties.password") . With ( passwordElement =>
154
154
{
155
+ #if ! NET6_0
156
+ passwordElement . Should ( ) . HaveProperty ( "maxLength" , 100 ) ;
157
+ passwordElement . Should ( ) . HaveProperty ( "minLength" , 5 ) ;
158
+ #endif
155
159
passwordElement . Should ( ) . HaveProperty ( "type" , "string" ) ;
156
160
} ) ;
157
161
}
158
162
159
163
[ Theory ]
160
- [ MemberData ( nameof ( ModelNames ) ) ]
164
+ [ MemberData ( nameof ( SchemaNames ) ) ]
161
165
public async Task Phone_annotation_on_resource_property_produces_expected_schema ( string modelName )
162
166
{
163
167
// Act
@@ -172,7 +176,7 @@ public async Task Phone_annotation_on_resource_property_produces_expected_schema
172
176
}
173
177
174
178
[ Theory ]
175
- [ MemberData ( nameof ( ModelNames ) ) ]
179
+ [ MemberData ( nameof ( SchemaNames ) ) ]
176
180
public async Task Range_annotation_on_resource_property_produces_expected_schema ( string modelName )
177
181
{
178
182
// Act
@@ -191,7 +195,7 @@ public async Task Range_annotation_on_resource_property_produces_expected_schema
191
195
}
192
196
193
197
[ Theory ]
194
- [ MemberData ( nameof ( ModelNames ) ) ]
198
+ [ MemberData ( nameof ( SchemaNames ) ) ]
195
199
public async Task Url_annotation_on_resource_property_produces_expected_schema ( string modelName )
196
200
{
197
201
// Act
@@ -206,7 +210,7 @@ public async Task Url_annotation_on_resource_property_produces_expected_schema(s
206
210
}
207
211
208
212
[ Theory ]
209
- [ MemberData ( nameof ( ModelNames ) ) ]
213
+ [ MemberData ( nameof ( SchemaNames ) ) ]
210
214
public async Task Uri_type_produces_expected_schema ( string modelName )
211
215
{
212
216
// Act
@@ -221,7 +225,7 @@ public async Task Uri_type_produces_expected_schema(string modelName)
221
225
}
222
226
223
227
[ Theory ]
224
- [ MemberData ( nameof ( ModelNames ) ) ]
228
+ [ MemberData ( nameof ( SchemaNames ) ) ]
225
229
public async Task Length_annotation_on_resource_list_property_produces_expected_schema ( string modelName )
226
230
{
227
231
// Act
@@ -244,35 +248,7 @@ public async Task Length_annotation_on_resource_list_property_produces_expected_
244
248
}
245
249
246
250
[ Theory ]
247
- [ MemberData ( nameof ( ModelNames ) ) ]
248
- public async Task AllowedValues_annotation_on_resource_list_property_produces_expected_schema ( string modelName )
249
- {
250
- // Act
251
- JsonElement document = await _testContext . GetSwaggerDocumentAsync ( ) ;
252
-
253
- // Assert
254
- document . Should ( ) . ContainPath ( $ "components.schemas.{ modelName } .properties.countryCode") . With ( countryCodeElement =>
255
- {
256
- countryCodeElement . Should ( ) . HaveProperty ( "type" , "string" ) ;
257
- } ) ;
258
- }
259
-
260
- [ Theory ]
261
- [ MemberData ( nameof ( ModelNames ) ) ]
262
- public async Task DeniedValues_annotation_on_resource_property_produces_expected_schema ( string modelName )
263
- {
264
- // Act
265
- JsonElement document = await _testContext . GetSwaggerDocumentAsync ( ) ;
266
-
267
- // Assert
268
- document . Should ( ) . ContainPath ( $ "components.schemas.{ modelName } .properties.planet") . With ( planetElement =>
269
- {
270
- planetElement . Should ( ) . HaveProperty ( "type" , "string" ) ;
271
- } ) ;
272
- }
273
-
274
- [ Theory ]
275
- [ MemberData ( nameof ( ModelNames ) ) ]
251
+ [ MemberData ( nameof ( SchemaNames ) ) ]
276
252
public async Task TimeSpan_range_annotation_on_resource_property_produces_expected_schema ( string modelName )
277
253
{
278
254
// Act
@@ -287,7 +263,7 @@ public async Task TimeSpan_range_annotation_on_resource_property_produces_expect
287
263
}
288
264
289
265
[ Theory ]
290
- [ MemberData ( nameof ( ModelNames ) ) ]
266
+ [ MemberData ( nameof ( SchemaNames ) ) ]
291
267
public async Task DateTime_type_produces_expected_schema ( string modelName )
292
268
{
293
269
// Act
@@ -302,7 +278,7 @@ public async Task DateTime_type_produces_expected_schema(string modelName)
302
278
}
303
279
304
280
[ Theory ]
305
- [ MemberData ( nameof ( ModelNames ) ) ]
281
+ [ MemberData ( nameof ( SchemaNames ) ) ]
306
282
public async Task DateOnly_type_produces_expected_schema ( string modelName )
307
283
{
308
284
// Act
@@ -317,7 +293,7 @@ public async Task DateOnly_type_produces_expected_schema(string modelName)
317
293
}
318
294
319
295
[ Theory ]
320
- [ MemberData ( nameof ( ModelNames ) ) ]
296
+ [ MemberData ( nameof ( SchemaNames ) ) ]
321
297
public async Task TimeOnly_type_produces_expected_schema ( string modelName )
322
298
{
323
299
// Act
0 commit comments