This repository was archived by the owner on Nov 11, 2025. It is now read-only.
forked from microsoft/OpenAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenApiPathItemDeserializerTests.cs
More file actions
52 lines (42 loc) · 2.21 KB
/
OpenApiPathItemDeserializerTests.cs
File metadata and controls
52 lines (42 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
}
}