forked from microsoft/OpenAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
add V3.2 properties on OpenApiTag #33
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
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e791bf6
add V3.2 properties on OpenApiTag
kilifu 77d2c23
fix serializeAsVX
kilifu 4d780a6
add models/openapitagtests
kilifu 1852b87
Merge branch 'feat/oai-3-2-support' into feat/add-new-fields-tags
baywet b7e91fe
retour PR
kilifu c7f9120
Merge branch 'feat/add-new-fields-tags' of https://github.com/BinkyLa…
kilifu 2837c4a
Update src/Microsoft.OpenApi/Models/OpenApiTag.cs
kilifu 60e9b13
Update src/Microsoft.OpenApi/Models/OpenApiTag.cs
kilifu 6b99fc0
Update src/Microsoft.OpenApi/Models/OpenApiTag.cs
kilifu c28e858
Update src/Microsoft.OpenApi/Models/OpenApiTag.cs
kilifu 9ab8890
Update src/Microsoft.OpenApi/Models/OpenApiTag.cs
kilifu b9976d4
if the Target is a reference, and reference equals this, return null,…
kilifu ab8286e
Merge branch 'feat/oai-3-2-support' into feat/add-new-fields-tags
baywet f550dc8
chore: fixes reference comparison
baywet 75b009d
chore: refreshes benchmarks
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
83 changes: 83 additions & 0 deletions
83
test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiTagDeserializerTests.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,83 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Nodes; | ||
using Microsoft.OpenApi.Reader; | ||
using Microsoft.OpenApi.Reader.V31; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V31Tests; | ||
|
||
public class OpenApiTagDeserializerTests | ||
{ | ||
[Fact] | ||
public void ShouldDeserializeTagWithNewV31Properties() | ||
{ | ||
var json = | ||
""" | ||
{ | ||
"name": "store", | ||
"description": "Store operations", | ||
"x-oas-summary": "Operations related to the pet store", | ||
"x-oas-parent": "pet", | ||
"x-oas-kind": "operational", | ||
"externalDocs": { | ||
"description": "Find more info here", | ||
"url": "https://example.com/" | ||
}, | ||
"x-custom-extension": "test-value" | ||
} | ||
"""; | ||
|
||
var hostDocument = new OpenApiDocument(); | ||
hostDocument.Tags ??= new HashSet<OpenApiTag>(); | ||
hostDocument.Tags.Add(new OpenApiTag | ||
{ | ||
Name = "pet", | ||
Description = "Parent tag for pets operations", | ||
}); | ||
|
||
var jsonNode = JsonNode.Parse(json); | ||
var parseNode = ParseNode.Create(new ParsingContext(new()), jsonNode); | ||
|
||
var result = OpenApiV31Deserializer.LoadTag(parseNode, hostDocument); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal("store", result.Name); | ||
Assert.Equal("Store operations", result.Description); | ||
Assert.Equal("Operations related to the pet store", result.Summary); | ||
Assert.Equal("operational", result.Kind); | ||
Assert.NotNull(result.Parent); | ||
Assert.Equal("pet", result.Parent.Reference.Id); | ||
Assert.NotNull(result.ExternalDocs); | ||
Assert.Equal("Find more info here", result.ExternalDocs.Description); | ||
Assert.Equal("https://example.com/", result.ExternalDocs.Url?.ToString()); | ||
Assert.NotNull(result.Extensions); | ||
Assert.Single(result.Extensions); | ||
Assert.True(result.Extensions.ContainsKey("x-custom-extension")); | ||
} | ||
|
||
[Fact] | ||
public void ShouldDeserializeTagWithBasicProperties() | ||
{ | ||
var json = | ||
""" | ||
{ | ||
"name": "pets", | ||
"description": "Pet operations", | ||
"x-oas-summary": "All operations for managing pets" | ||
} | ||
"""; | ||
|
||
var hostDocument = new OpenApiDocument(); | ||
var jsonNode = JsonNode.Parse(json); | ||
var parseNode = ParseNode.Create(new ParsingContext(new()), jsonNode); | ||
|
||
var result = OpenApiV31Deserializer.LoadTag(parseNode, hostDocument); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal("pets", result.Name); | ||
Assert.Equal("Pet operations", result.Description); | ||
Assert.Equal("All operations for managing pets", result.Summary); | ||
Assert.Null(result.Parent); | ||
Assert.Null(result.Kind); | ||
} | ||
} |
Oops, something went wrong.
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.