forked from microsoft/OpenAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for dataValue and serializedValue in OpenApiExample #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
baywet
merged 7 commits into
feat/oai-3-2-support
from
copilot/fix-74a1e771-9ced-4ec8-9483-9ee135a0c31b
Oct 1, 2025
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b50a07d
Initial plan
Copilot 6966be5
Add DataValue and SerializedValue properties to OpenApiExample
Copilot c39da76
Add serialization and deserialization tests for new OpenApiExample fi…
Copilot 33a219e
Update public API export file for new OpenApiExample properties
Copilot 688fcc5
Rewrite test assertions to use Assert methods instead of FluentAssert…
Copilot 31610db
Merge branch 'feat/oai-3-2-support' into copilot/fix-74a1e771-9ced-4e…
baywet ccef12b
chore: updates benchmark results
baywet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiExampleTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.IO; | ||
using System.Text.Json.Nodes; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Microsoft.OpenApi.Reader; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V31Tests | ||
{ | ||
[Collection("DefaultSettings")] | ||
public class OpenApiExampleTests | ||
{ | ||
private const string SampleFolderPath = "V31Tests/Samples/OpenApiExample/"; | ||
|
||
[Fact] | ||
public async Task ParseExampleWithDataValueExtensionShouldSucceed() | ||
{ | ||
// Arrange & Act | ||
var example = await OpenApiModelFactory.LoadAsync<OpenApiExample>( | ||
Path.Combine(SampleFolderPath, "exampleWithDataValue.yaml"), | ||
OpenApiSpecVersion.OpenApi3_1, | ||
new(), | ||
SettingsFixture.ReaderSettings); | ||
|
||
// Assert | ||
example.Should().NotBeNull(); | ||
example.Summary.Should().Be("Example with dataValue (extension)"); | ||
example.DataValue.Should().NotBeNull(); | ||
example.DataValue["name"].GetValue<string>().Should().Be("Jane Smith"); | ||
example.DataValue["age"].GetValue<decimal>().Should().Be(25); | ||
} | ||
|
||
[Fact] | ||
public async Task ParseExampleWithSerializedValueExtensionShouldSucceed() | ||
{ | ||
// Arrange & Act | ||
var example = await OpenApiModelFactory.LoadAsync<OpenApiExample>( | ||
Path.Combine(SampleFolderPath, "exampleWithSerializedValue.yaml"), | ||
OpenApiSpecVersion.OpenApi3_1, | ||
new(), | ||
SettingsFixture.ReaderSettings); | ||
|
||
// Assert | ||
example.Should().NotBeNull(); | ||
example.Summary.Should().Be("Example with serializedValue (extension)"); | ||
example.SerializedValue.Should().Be("custom serialized string with extension"); | ||
baywet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiExample/exampleWithDataValue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
summary: Example with dataValue (extension) | ||
x-oai-dataValue: | ||
name: Jane Smith | ||
age: 25 |
2 changes: 2 additions & 0 deletions
2
...oft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiExample/exampleWithSerializedValue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
summary: Example with serializedValue (extension) | ||
x-oai-serializedValue: "custom serialized string with extension" |
52 changes: 52 additions & 0 deletions
52
test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiExampleTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.IO; | ||
using System.Text.Json.Nodes; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Microsoft.OpenApi.Reader; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V32Tests | ||
{ | ||
[Collection("DefaultSettings")] | ||
public class OpenApiExampleTests | ||
{ | ||
private const string SampleFolderPath = "V32Tests/Samples/OpenApiExample/"; | ||
|
||
[Fact] | ||
public async Task ParseExampleWithDataValueShouldSucceed() | ||
{ | ||
// Arrange & Act | ||
var example = await OpenApiModelFactory.LoadAsync<OpenApiExample>( | ||
Path.Combine(SampleFolderPath, "exampleWithDataValue.yaml"), | ||
OpenApiSpecVersion.OpenApi3_2, | ||
new(), | ||
SettingsFixture.ReaderSettings); | ||
|
||
// Assert | ||
example.Should().NotBeNull(); | ||
example.Summary.Should().Be("Example with dataValue"); | ||
example.DataValue.Should().NotBeNull(); | ||
example.DataValue["name"].GetValue<string>().Should().Be("John Doe"); | ||
example.DataValue["age"].GetValue<decimal>().Should().Be(30); | ||
baywet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
[Fact] | ||
public async Task ParseExampleWithSerializedValueShouldSucceed() | ||
{ | ||
// Arrange & Act | ||
var example = await OpenApiModelFactory.LoadAsync<OpenApiExample>( | ||
Path.Combine(SampleFolderPath, "exampleWithSerializedValue.yaml"), | ||
OpenApiSpecVersion.OpenApi3_2, | ||
new(), | ||
SettingsFixture.ReaderSettings); | ||
|
||
// Assert | ||
example.Should().NotBeNull(); | ||
example.Summary.Should().Be("Example with serializedValue"); | ||
example.SerializedValue.Should().Be("custom serialized string"); | ||
baywet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...Microsoft.OpenApi.Readers.Tests/V32Tests/Samples/OpenApiExample/exampleWithDataValue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
summary: Example with dataValue | ||
dataValue: | ||
name: John Doe | ||
age: 30 |
2 changes: 2 additions & 0 deletions
2
...oft.OpenApi.Readers.Tests/V32Tests/Samples/OpenApiExample/exampleWithSerializedValue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
summary: Example with serializedValue | ||
serializedValue: "custom serialized string" |
7 changes: 7 additions & 0 deletions
7
...ts.SerializeExampleWithDataValueAsV31JsonWorksAsync_produceTerseOutput=False.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"summary": "Example with dataValue", | ||
"x-oai-dataValue": { | ||
"name": "John Doe", | ||
"age": 30 | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...sts.SerializeExampleWithDataValueAsV31JsonWorksAsync_produceTerseOutput=True.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"summary":"Example with dataValue","x-oai-dataValue":{"name":"John Doe","age":30}} |
7 changes: 7 additions & 0 deletions
7
...ts.SerializeExampleWithDataValueAsV32JsonWorksAsync_produceTerseOutput=False.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"summary": "Example with dataValue", | ||
"dataValue": { | ||
"name": "John Doe", | ||
"age": 30 | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...sts.SerializeExampleWithDataValueAsV32JsonWorksAsync_produceTerseOutput=True.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"summary":"Example with dataValue","dataValue":{"name":"John Doe","age":30}} |
4 changes: 4 additions & 0 deletions
4
...ializeExampleWithSerializedValueAsV31JsonWorksAsync_produceTerseOutput=False.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"summary": "Example with serializedValue", | ||
"x-oai-serializedValue": "custom serialized string" | ||
} |
1 change: 1 addition & 0 deletions
1
...rializeExampleWithSerializedValueAsV31JsonWorksAsync_produceTerseOutput=True.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"summary":"Example with serializedValue","x-oai-serializedValue":"custom serialized string"} |
4 changes: 4 additions & 0 deletions
4
...ializeExampleWithSerializedValueAsV32JsonWorksAsync_produceTerseOutput=False.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"summary": "Example with serializedValue", | ||
"serializedValue": "custom serialized string" | ||
} |
1 change: 1 addition & 0 deletions
1
...rializeExampleWithSerializedValueAsV32JsonWorksAsync_produceTerseOutput=True.verified.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"summary":"Example with serializedValue","serializedValue":"custom serialized string"} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.