forked from microsoft/OpenAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
add new v32 properties for Path Items #34
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 all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
93d8a47
add new v32 properties for Path Items
kilifu 9f0d2c1
Merge branch 'feat/oai-3-2-support' into feat/5-new-fields-path-item
baywet 1cac1a2
move query and AdditionalOperations to OpenApiOperation
kilifu e3ae554
Merge branch 'feat/5-new-fields-path-item' of https://github.com/Bink…
kilifu 40a22f8
Merge branch 'feat/oai-3-2-support' into feat/5-new-fields-path-item
kilifu a256053
chore: reverts some undesired changes
baywet f7dc7ee
feat: adds support for additional operations in OAI 3.2
baywet d608cdc
chore: linting
baywet 1a104d9
chore: fixes test files for path item additional operations
baywet c6b1b0e
chore: updates public export
baywet 4801b06
chore: make new unit tests build
baywet 0520443
chore: refactoring
baywet 4f47916
tests: fixes additional operation test file
baywet 71e51ea
tests: fixes test definitions
baywet cbc2934
fix: do not serialized extraneous operations in v2
baywet 39f300d
tests: fixes unit tests for path item serialization
baywet 30227ef
Merge branch 'feat/oai-3-2-support' into feat/5-new-fields-path-item
baywet fefec09
test: adds tests for 30 deserialization of path items with extra ops
baywet 0781a89
chore: moves tests definitions to the right location
baywet 49f9560
tests: adds deserialization tests for 3.1 path item extra operations
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
47 changes: 47 additions & 0 deletions
47
test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiPathItemDeserializerTests.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,47 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Text.Json.Nodes; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V31Tests; | ||
|
||
public class OpenApiPathItemDeserializerTests | ||
{ | ||
private const string SampleFolderPath = "V31Tests/Samples/OpenApiPathItem/"; | ||
|
||
[Fact] | ||
public async Task ExtraneousOperationsAreParsedAsExtensionsIn31() | ||
{ | ||
// Arrange & Act | ||
var result = await OpenApiDocument.LoadAsync($"{SampleFolderPath}pathItemWithQueryAndAdditionalOperations.yaml", SettingsFixture.ReaderSettings); | ||
var pathItem = result.Document.Paths["/pets"]; | ||
|
||
// Assert | ||
Assert.Equal("Pet operations", pathItem.Summary); | ||
Assert.Equal("Operations available for pets", pathItem.Description); | ||
|
||
// Regular operations | ||
var getOp = Assert.Contains(HttpMethod.Get, pathItem.Operations); | ||
Assert.Equal("getPets", getOp.OperationId); | ||
|
||
var postOp = Assert.Contains(HttpMethod.Post, pathItem.Operations); | ||
Assert.Equal("createPet", postOp.OperationId); | ||
|
||
// Query operation should now be on one of the operations | ||
// Since the YAML structure changed, we need to check which operation has the query | ||
Assert.DoesNotContain(new HttpMethod("Query"), pathItem.Operations); | ||
Assert.DoesNotContain(new HttpMethod("notify"), pathItem.Operations); | ||
Assert.DoesNotContain(new HttpMethod("subscribe"), pathItem.Operations); | ||
|
||
var additionalPathsExt = Assert.IsType<JsonNodeExtension>(Assert.Contains("x-oai-additionalOperations", pathItem.Extensions)); | ||
|
||
var additionalOpsNode = Assert.IsType<JsonObject>(additionalPathsExt.Node); | ||
Assert.Contains("query", additionalOpsNode); | ||
Assert.Contains("notify", additionalOpsNode); | ||
Assert.Contains("subscribe", additionalOpsNode); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...ders.Tests/V31Tests/Samples/OpenApiPathItem/pathItemWithQueryAndAdditionalOperations.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,77 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: PathItem with Query and AdditionalOperations | ||
version: 1.0.0 | ||
paths: | ||
/pets: | ||
summary: Pet operations | ||
description: Operations available for pets | ||
get: | ||
summary: Get pets | ||
operationId: getPets | ||
responses: | ||
'200': | ||
description: List of pets | ||
x-oai-additionalOperations: | ||
query: | ||
summary: Query pets with complex filters | ||
operationId: queryPets | ||
parameters: | ||
- name: filter | ||
in: query | ||
description: Complex filter expression | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Filtered pets | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
type: object | ||
notify: | ||
summary: Notify about pet updates | ||
operationId: notifyPetUpdates | ||
requestBody: | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
petId: | ||
type: string | ||
event: | ||
type: string | ||
responses: | ||
'200': | ||
description: Notification sent | ||
subscribe: | ||
summary: Subscribe to pet events | ||
operationId: subscribePetEvents | ||
parameters: | ||
- name: events | ||
in: query | ||
description: Event types to subscribe to | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
responses: | ||
'200': | ||
description: Subscription created | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
subscriptionId: | ||
type: string | ||
post: | ||
summary: Create pet | ||
operationId: createPet | ||
responses: | ||
'201': | ||
description: Pet created |
52 changes: 52 additions & 0 deletions
52
test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiPathItemDeserializerTests.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.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V32Tests; | ||
|
||
public class OpenApiPathItemDeserializerTests | ||
{ | ||
private const string SampleFolderPath = "V32Tests/Samples/OpenApiPathItem/"; | ||
|
||
[Fact] | ||
public async Task ParsePathItemWithQueryAndAdditionalOperationsV32Works() | ||
{ | ||
// Arrange & Act | ||
var result = await OpenApiDocument.LoadAsync($"{SampleFolderPath}pathItemWithQueryAndAdditionalOperations.yaml", SettingsFixture.ReaderSettings); | ||
var pathItem = result.Document.Paths["/pets"]; | ||
|
||
// Assert | ||
Assert.Equal("Pet operations", pathItem.Summary); | ||
Assert.Equal("Operations available for pets", pathItem.Description); | ||
|
||
// Regular operations | ||
var getOp = Assert.Contains(HttpMethod.Get, pathItem.Operations); | ||
Assert.Equal("getPets", getOp.OperationId); | ||
|
||
var postOp = Assert.Contains(HttpMethod.Post, pathItem.Operations); | ||
Assert.Equal("createPet", postOp.OperationId); | ||
|
||
// Query operation should now be on one of the operations | ||
// Since the YAML structure changed, we need to check which operation has the query | ||
var queryOp = Assert.Contains(new HttpMethod("Query"), pathItem.Operations); | ||
Assert.Equal("Query pets with complex filters", queryOp.Summary); | ||
Assert.Equal("queryPets", queryOp.OperationId); | ||
Assert.Single(queryOp.Parameters); | ||
Assert.Equal("filter", queryOp.Parameters[0].Name); | ||
|
||
var notifyOp = Assert.Contains(new HttpMethod("notify"), pathItem.Operations); | ||
Assert.Equal("Notify about pet updates", notifyOp.Summary); | ||
Assert.Equal("notifyPetUpdates", notifyOp.OperationId); | ||
Assert.NotNull(notifyOp.RequestBody); | ||
|
||
var subscribeOp = Assert.Contains(new HttpMethod("subscribe"), pathItem.Operations); | ||
Assert.Equal("Subscribe to pet events", subscribeOp.Summary); | ||
Assert.Equal("subscribePetEvents", subscribeOp.OperationId); | ||
Assert.Single(subscribeOp.Parameters); | ||
Assert.Equal("events", subscribeOp.Parameters[0].Name); | ||
} | ||
} |
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.