Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c0c4621

Browse filesBrowse files
authored
Merge pull request #2654 from microsoft/fix/additional-properties-false-to-v3
fix/additional properties false to v3
2 parents 3d32655 + 1bb7dcb commit c0c4621
Copy full SHA for c0c4621

3 files changed

+21-9Lines changed: 21 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+13-3Lines changed: 13 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
## [3.1.0](https://github.com/microsoft/OpenAPI.NET/compare/v3.0.3...v3.1.0) (2025-12-17)
44

5-
65
### Features
76

87
* Add `type: "null"` downcasting when in oneOf and anyOf for OpenAPI v3 ([782cf8d](https://github.com/microsoft/OpenAPI.NET/commit/782cf8d1ff8166e3c7be706e08dabf168b9616a4))
98

109
## [3.0.3](https://github.com/microsoft/OpenAPI.NET/compare/v3.0.2...v3.0.3) (2025-12-16)
1110

12-
### Bug Fixes
1311

1412
* load JSON documents that are preceded by multiple whitespace ([6461bac](https://github.com/microsoft/OpenAPI.NET/commit/6461bac01c4176424210e9ac249698f665a514a6))
1513
* non-seekable json streams would fail to load as a document ([2436d73](https://github.com/microsoft/OpenAPI.NET/commit/2436d7382bfbf8b9ba501d88f682e952bdf27146))
@@ -43,8 +41,20 @@
4341

4442
* adds support for OpenAPI 3.2.0 ([765a8dd](https://github.com/microsoft/OpenAPI.NET/commit/765a8dd4d6efd1a31b6a76d282ccffa5877a845a))
4543

46-
## [2.3.12](https://github.com/microsoft/OpenAPI.NET/compare/v2.3.11...v2.3.12) (2025-12-15)
44+
## [2.4.1](https://github.com/microsoft/OpenAPI.NET/compare/v2.4.0...v2.4.1) (2025-12-18)
45+
46+
### Bug Fixes
47+
48+
* **schema:** always serialize `additionalProperties: false` ([6651c36](https://github.com/microsoft/OpenAPI.NET/commit/6651c36ff341329c053776d65b36b1b7fa9dd3ea))
49+
* **schema:** always serialize `additionalProperties: false` ([e36fc95](https://github.com/microsoft/OpenAPI.NET/commit/e36fc9565bce42916eb7bf64d1f74d491dd1f407))
4750

51+
## [2.4.0](https://github.com/microsoft/OpenAPI.NET/compare/v2.3.12...v2.4.0) (2025-12-17)
52+
53+
### Features
54+
55+
* Add `type: "null"` downcasting when in oneOf and anyOf for OpenAPI v3 ([782cf8d](https://github.com/microsoft/OpenAPI.NET/commit/782cf8d1ff8166e3c7be706e08dabf168b9616a4))
56+
57+
## [2.3.12](https://github.com/microsoft/OpenAPI.NET/compare/v2.3.11...v2.3.12) (2025-12-15)
4858

4959
### Bug Fixes
5060

Collapse file

‎src/Microsoft.OpenApi/Models/OpenApiSchema.cs‎

Copy file name to clipboardExpand all lines: src/Microsoft.OpenApi/Models/OpenApiSchema.cs
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,8 @@ private void SerializeInternal(IOpenApiWriter writer, OpenApiSpecVersion version
494494
AdditionalProperties,
495495
callback);
496496
}
497-
// true is the default in earlier versions 3, no need to write it out
498-
// boolean value is only supported for version 3 and earlier (version 2 is implemented in the other serialize method, the condition is a failsafe)
499-
else if (!AdditionalPropertiesAllowed && version <= OpenApiSpecVersion.OpenApi3_0)
497+
// true is the default, no need to write it out
498+
else if (!AdditionalPropertiesAllowed)
500499
{
501500
writer.WriteProperty(OpenApiConstants.AdditionalProperties, AdditionalPropertiesAllowed);
502501
}
Collapse file

‎test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs‎

Copy file name to clipboardExpand all lines: test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,11 @@ public async Task SerializeAdditionalPropertiesAllowedAsV3PlusDefaultDoesNotEmit
755755
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expected), JsonNode.Parse(actual)));
756756
}
757757

758-
[Fact]
759-
public async Task SerializeAdditionalPropertiesAllowedAsV3FalseEmits()
758+
[Theory]
759+
[InlineData(OpenApiSpecVersion.OpenApi3_0)]
760+
[InlineData(OpenApiSpecVersion.OpenApi3_1)]
761+
[InlineData(OpenApiSpecVersion.OpenApi3_2)]
762+
public async Task SerializeAdditionalPropertiesAllowedAsV3PlusFalseEmits(OpenApiSpecVersion version)
760763
{
761764
var expected = @"{ ""additionalProperties"": false }";
762765
// Given
@@ -766,7 +769,7 @@ public async Task SerializeAdditionalPropertiesAllowedAsV3FalseEmits()
766769
};
767770

768771
// When
769-
var actual = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
772+
var actual = await schema.SerializeAsJsonAsync(version);
770773

771774
// Then
772775
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(expected), JsonNode.Parse(actual)));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.