-
Notifications
You must be signed in to change notification settings - Fork 306
Fix empty objects in plugin manifests by omitting them instead of serializing empty {} #6945
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
Open
Copilot
wants to merge
12
commits into
main
Choose a base branch
from
copilot/fix-6944
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b2def3a
Initial plan
Copilot 2c56a29
Initial analysis of empty object issue in plugin manifests
Copilot 754ca72
Fix empty objects in plugin manifests by omitting them instead of ser…
Copilot c6bd1e1
Fix additional OpenApi extensions with empty object issues and add co…
Copilot 6fb023f
Apply suggestion from @baywet
sebastienlevert 944109e
Remove unnecessary Microsoft.OpenApi.Writers import causing compilati…
Copilot 003cf9c
Run dotnet format to fix formatting issues
Copilot 369292f
chore: reverts copilot hallucinations
baywet 491eeb2
Merge branch 'main' into copilot/fix-6944
sebastienlevert bc1b3f9
Re-apply fix for empty x-ai-capabilities after merge conflict resolution
Copilot 32d6554
Don't create conversation starters for operations with empty x-ai-cap…
Copilot e149f4a
Apply dotnet format to fix code formatting issues
Copilot 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
Some comments aren't visible on the classic Files Changed page.
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
78 changes: 78 additions & 0 deletions
78
tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiLogoExtensionTests.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,78 @@ | ||
| using System.IO; | ||
| using System.Text.Json.Nodes; | ||
| using Kiota.Builder.OpenApiExtensions; | ||
| using Microsoft.OpenApi; | ||
| using Microsoft.OpenApi.Writers; | ||
|
Check failure on line 5 in tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiLogoExtensionTests.cs
|
||
| using Xunit; | ||
|
|
||
| namespace Kiota.Builder.Tests.OpenApiExtensions; | ||
|
|
||
| public sealed class OpenApiLogoExtensionTest | ||
| { | ||
| [Fact] | ||
| public void Parses() | ||
| { | ||
| var oaiValueRepresentation = | ||
| """ | ||
| { | ||
| "url": "https://example.com/logo.png" | ||
| } | ||
| """; | ||
| using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(oaiValueRepresentation)); | ||
| var oaiValue = JsonNode.Parse(stream); | ||
| var value = OpenApiLogoExtension.Parse(oaiValue); | ||
|
|
||
| Assert.NotNull(value); | ||
| Assert.Equal("https://example.com/logo.png", value.Url); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Serializes() | ||
| { | ||
| var value = new OpenApiLogoExtension | ||
| { | ||
| Url = "https://example.com/logo.png" | ||
| }; | ||
| using var sWriter = new StringWriter(); | ||
| OpenApiJsonWriter writer = new(sWriter, new OpenApiJsonWriterSettings { Terse = true }); | ||
|
|
||
| value.Write(writer, OpenApiSpecVersion.OpenApi3_0); | ||
| var result = sWriter.ToString(); | ||
|
|
||
| Assert.Equal("{\"url\":\"https://example.com/logo.png\"}", result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WritesNothingForEmptyLogo() | ||
| { | ||
| var value = new OpenApiLogoExtension | ||
| { | ||
| Url = null | ||
| }; | ||
| using var sWriter = new StringWriter(); | ||
| OpenApiJsonWriter writer = new(sWriter, new OpenApiJsonWriterSettings { Terse = true }); | ||
|
|
||
| value.Write(writer, OpenApiSpecVersion.OpenApi3_0); | ||
| var result = sWriter.ToString(); | ||
|
|
||
| // When Url is null/empty, nothing should be written | ||
| Assert.Equal(string.Empty, result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WritesNothingForEmptyUrlString() | ||
| { | ||
| var value = new OpenApiLogoExtension | ||
| { | ||
| Url = string.Empty | ||
| }; | ||
| using var sWriter = new StringWriter(); | ||
| OpenApiJsonWriter writer = new(sWriter, new OpenApiJsonWriterSettings { Terse = true }); | ||
|
|
||
| value.Write(writer, OpenApiSpecVersion.OpenApi3_0); | ||
| var result = sWriter.ToString(); | ||
|
|
||
| // When Url is empty string, nothing should be written | ||
| Assert.Equal(string.Empty, result); | ||
| } | ||
| } | ||
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
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.