Skip to content

Commit 0cfe1f7

Browse files
committed
Fix .NET 8 things
1 parent 10fe4ac commit 0cfe1f7

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

package-versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<CodeAnalysisFrozenVersion>4.1.0</CodeAnalysisFrozenVersion>
55
<DemystifierFrozenVersion>0.4.1</DemystifierFrozenVersion>
66
<HumanizerFrozenVersion>2.14.1</HumanizerFrozenVersion>
7-
<SwashbuckleFrozenVersion>6.6.1</SwashbuckleFrozenVersion>
7+
<SwashbuckleFrozenVersion>6.6.2</SwashbuckleFrozenVersion>
88
<NewtonsoftJsonFrozenVersion>13.0.3</NewtonsoftJsonFrozenVersion>
99

1010
<!-- Non-published dependencies (these are safe to update, won't cause a breaking change) -->

test/OpenApiTests/ModelStateValidation/GeneratedSwagger/net8.0/swagger.g.json

+12
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@
405405
"nullable": true
406406
},
407407
"firstName": {
408+
"maxLength": 20,
409+
"minLength": 2,
408410
"type": "string",
409411
"nullable": true
410412
},
@@ -459,6 +461,8 @@
459461
"nullable": true
460462
},
461463
"tags": {
464+
"maxItems": 10,
465+
"minItems": 1,
462466
"type": "array",
463467
"items": {
464468
"type": "string"
@@ -508,6 +512,8 @@
508512
"nullable": true
509513
},
510514
"firstName": {
515+
"maxLength": 20,
516+
"minLength": 2,
511517
"type": "string",
512518
"nullable": true
513519
},
@@ -562,6 +568,8 @@
562568
"nullable": true
563569
},
564570
"tags": {
571+
"maxItems": 10,
572+
"minItems": 1,
565573
"type": "array",
566574
"items": {
567575
"type": "string"
@@ -608,6 +616,8 @@
608616
"nullable": true
609617
},
610618
"firstName": {
619+
"maxLength": 20,
620+
"minLength": 2,
611621
"type": "string",
612622
"nullable": true
613623
},
@@ -662,6 +672,8 @@
662672
"nullable": true
663673
},
664674
"tags": {
675+
"maxItems": 10,
676+
"minItems": 1,
665677
"type": "array",
666678
"items": {
667679
"type": "string"

test/OpenApiTests/ModelStateValidation/ModelStateValidationTests.cs

+27-5
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ public async Task Guid_type_produces_expected_schema(string modelName)
4242

4343
[Theory]
4444
[MemberData(nameof(ModelNames))]
45-
public async Task Length_annotation_on_resource_property_produces_expected_schema(string modelName)
45+
public async Task Length_annotation_on_resource_string_property_produces_expected_schema(string modelName)
4646
{
4747
// Act
4848
JsonElement document = await _testContext.GetSwaggerDocumentAsync();
4949

5050
// Assert
51-
document.Should().ContainPath($"components.schemas.{modelName}.properties.firstName").With(firstName =>
51+
document.Should().ContainPath($"components.schemas.{modelName}.properties.firstName").With(firstNameElement =>
5252
{
53-
firstName.Should().HaveProperty("type", "string");
53+
#if !NET6_0
54+
firstNameElement.Should().HaveProperty("maxLength", 20);
55+
firstNameElement.Should().HaveProperty("minLength", 2);
56+
#endif
57+
firstNameElement.Should().HaveProperty("type", "string");
5458
});
5559
}
5660

@@ -224,14 +228,18 @@ public async Task Uri_type_produces_expected_schema(string modelName)
224228

225229
[Theory]
226230
[MemberData(nameof(ModelNames))]
227-
public async Task HashSet_type_produces_expected_schema(string modelName)
231+
public async Task Length_annotation_on_resource_list_property_produces_expected_schema(string modelName)
228232
{
229233
// Act
230234
JsonElement document = await _testContext.GetSwaggerDocumentAsync();
231235

232236
// Assert
233237
document.Should().ContainPath($"components.schemas.{modelName}.properties.tags").With(tagsElement =>
234238
{
239+
#if !NET6_0
240+
tagsElement.Should().HaveProperty("maxItems", 10);
241+
tagsElement.Should().HaveProperty("minItems", 1);
242+
#endif
235243
tagsElement.Should().HaveProperty("type", "array");
236244
tagsElement.Should().ContainPath("items").With(itemsEl =>
237245
{
@@ -242,7 +250,21 @@ public async Task HashSet_type_produces_expected_schema(string modelName)
242250

243251
[Theory]
244252
[MemberData(nameof(ModelNames))]
245-
public async Task Allowed_denied_annotations_on_resource_property_produces_expected_schema(string modelName)
253+
public async Task AllowedValues_annotation_on_resource_list_property_produces_expected_schema(string modelName)
254+
{
255+
// Act
256+
JsonElement document = await _testContext.GetSwaggerDocumentAsync();
257+
258+
// Assert
259+
document.Should().ContainPath($"components.schemas.{modelName}.properties.countryCode").With(countryCodeElement =>
260+
{
261+
countryCodeElement.Should().HaveProperty("type", "string");
262+
});
263+
}
264+
265+
[Theory]
266+
[MemberData(nameof(ModelNames))]
267+
public async Task DeniedValues_annotation_on_resource_property_produces_expected_schema(string modelName)
246268
{
247269
// Act
248270
JsonElement document = await _testContext.GetSwaggerDocumentAsync();

0 commit comments

Comments
 (0)