Skip to content

Commit 498f51d

Browse files
committed
Added test for path item fragment
1 parent 866c02a commit 498f51d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System.Collections.Generic;
45
using System.IO;
56
using System.Linq;
67
using FluentAssertions;
@@ -200,6 +201,44 @@ public void ParseSimpleSchemaShouldSucceed()
200201
}
201202
}
202203

204+
[Fact]
205+
public void ParsePathFragmentShouldSucceed()
206+
{
207+
var input = @"
208+
summary: externally referenced path item
209+
get:
210+
responses:
211+
'200':
212+
description: Ok
213+
";
214+
var reader = new OpenApiStringReader();
215+
var diagnostic = new OpenApiDiagnostic();
216+
217+
// Act
218+
var openApiAny = reader.ReadFragment<OpenApiPathItem>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
219+
220+
// Assert
221+
diagnostic.ShouldBeEquivalentTo(new OpenApiDiagnostic());
222+
223+
openApiAny.ShouldBeEquivalentTo(
224+
new OpenApiPathItem
225+
{
226+
Summary = "externally referenced path item",
227+
Operations = new Dictionary<OperationType, OpenApiOperation>
228+
{
229+
[OperationType.Get] = new OpenApiOperation()
230+
{
231+
Responses = new OpenApiResponses
232+
{
233+
["200"] = new OpenApiResponse {
234+
Description = "Ok"
235+
}
236+
}
237+
}
238+
}
239+
});
240+
}
241+
203242
[Fact]
204243
public void ParseDictionarySchemaShouldSucceed()
205244
{

0 commit comments

Comments
 (0)