Skip to content

Commit 860c547

Browse files
committed
[Swashbuckle] ComplexValueObjectSchemaFilter sets "additionalProperties" to false because serializers are quite strict.
1 parent 8bd5f9d commit 860c547

File tree

34 files changed

+84
-47
lines changed

34 files changed

+84
-47
lines changed

samples/AspNetCore.Samples/AspNetCore.Samples_demo.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@
527527
"format": "double",
528528
"readOnly": true
529529
}
530-
}
530+
},
531+
"additionalProperties": false
531532
},
532533
"BoundaryWithFactories": {
533534
"type": "object",
@@ -542,7 +543,8 @@
542543
"format": "double",
543544
"readOnly": true
544545
}
545-
}
546+
},
547+
"additionalProperties": false
546548
},
547549
"NotificationChannelTypeDto": {
548550
"enum": [

src/Thinktecture.Runtime.Extensions.Swashbuckle/Swashbuckle/Internal/ComplexValueObjects/ComplexValueObjectSchemaFilter.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Reflection;
21
using Microsoft.OpenApi.Models;
32
using Swashbuckle.AspNetCore.SwaggerGen;
43
using Thinktecture.Internal;
@@ -43,9 +42,5 @@ public void Apply(OpenApiSchema schema, SchemaFilterContext context, Metadata.Co
4342
if (_requiredMemberEvaluator.IsRequired(schema, context, memberInfo))
4443
schema.Required.Add(memberInfo.Name);
4544
}
46-
47-
// Otherwise the type gets: "additionalProperties": false
48-
schema.AdditionalPropertiesAllowed = true;
49-
schema.AdditionalProperties = null;
5045
}
5146
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_body_parameter_endpointKind=Controller_nullable=False.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"format": "double",
5454
"readOnly": true
5555
}
56-
}
56+
},
57+
"additionalProperties": false
5758
}
5859
}
5960
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_body_parameter_endpointKind=Controller_nullable=True.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"format": "double",
5454
"readOnly": true
5555
}
56-
}
56+
},
57+
"additionalProperties": false
5758
}
5859
}
5960
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_body_parameter_endpointKind=MinimalApi_nullable=False.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
"format": "double",
5555
"readOnly": true
5656
}
57-
}
57+
},
58+
"additionalProperties": false
5859
}
5960
}
6061
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_body_parameter_endpointKind=MinimalApi_nullable=True.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"format": "double",
5454
"readOnly": true
5555
}
56-
}
56+
},
57+
"additionalProperties": false
5758
}
5859
}
5960
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_form_parameter_endpointKind=Controller_nullable=False.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"format": "double",
6868
"readOnly": true
6969
}
70-
}
70+
},
71+
"additionalProperties": false
7172
}
7273
}
7374
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_form_parameter_endpointKind=Controller_nullable=True.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"format": "double",
6868
"readOnly": true
6969
}
70-
}
70+
},
71+
"additionalProperties": false
7172
}
7273
}
7374
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_form_parameter_endpointKind=MinimalApi_nullable=False.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@
8888
"format": "double",
8989
"readOnly": true
9090
}
91-
}
91+
},
92+
"additionalProperties": false
9293
}
9394
}
9495
}

test/Thinktecture.Runtime.Extensions.Swashbuckle.Tests/Swashbuckle/ThinktectureSchemaFilterTests.ComplexValueObjects.Should_handle_Class_as_form_parameter_endpointKind=MinimalApi_nullable=True.verified.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"format": "double",
8383
"readOnly": true
8484
}
85-
}
85+
},
86+
"additionalProperties": false
8687
}
8788
}
8889
}

0 commit comments

Comments
 (0)