Skip to content

Commit 67a6b07

Browse files
authored
Merge pull request #947 from microsoft/vnext
Releases Hidi
2 parents b2f53ee + 8184eb2 commit 67a6b07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+814
-40
lines changed

Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -135,5 +135,22 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments
135135
var message2 = Assert.Throws<InvalidOperationException>(() => OpenApiFilterService.CreatePredicate("users.user.ListUser", "users.user")).Message;
136136
Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2);
137137
}
138+
139+
[Theory]
140+
[InlineData("reports.getTeamsUserActivityUserDetail-a3f1", null)]
141+
[InlineData(null, "reports.Functions")]
142+
public void ReturnsPathParametersOnSlicingBasedOnOperationIdsOrTags(string operationIds, string tags)
143+
{
144+
// Act
145+
var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags);
146+
var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate);
147+
148+
// Assert
149+
foreach (var pathItem in subsetOpenApiDocument.Paths)
150+
{
151+
Assert.True(pathItem.Value.Parameters.Any());
152+
Assert.Equal(1, pathItem.Value.Parameters.Count);
153+
}
154+
}
138155
}
139156
}

Microsoft.OpenApi.Hidi.Tests/UtilityFiles/OpenApiDocumentMock.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public static OpenApiDocument CreateOpenApiDocument()
116116
}
117117
}
118118
}
119+
},
120+
Parameters = new List<OpenApiParameter>
121+
{
122+
{
123+
new OpenApiParameter()
124+
{
125+
Name = "period",
126+
In = ParameterLocation.Path,
127+
Required = true,
128+
Schema = new OpenApiSchema()
129+
{
130+
Type = "string"
131+
}
132+
}
133+
}
119134
}
120135
},
121136
["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem()
@@ -175,7 +190,20 @@ public static OpenApiDocument CreateOpenApiDocument()
175190
}
176191
}
177192
}
178-
}
193+
},
194+
Parameters = new List<OpenApiParameter>
195+
{
196+
new OpenApiParameter
197+
{
198+
Name = "period",
199+
In = ParameterLocation.Path,
200+
Required = true,
201+
Schema = new OpenApiSchema()
202+
{
203+
Type = "string"
204+
}
205+
}
206+
}
179207
},
180208
["/users"] = new OpenApiPathItem()
181209
{

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1-*" PrivateAssets="All"/>
6+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
77
</ItemGroup>
88
</Project>

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
1616
<ToolCommandName>hidi</ToolCommandName>
1717
<PackageOutputPath>./../../artifacts</PackageOutputPath>
18-
<Version>1.0.0-preview8</Version>
18+
<Version>1.0.0-preview9</Version>
1919
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
2020
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2121
<PackageTags>OpenAPI .NET</PackageTags>
@@ -43,16 +43,12 @@
4343
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
4444
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
4545
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.0" />
46-
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview5" />
46+
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11" />
4747
</ItemGroup>
4848

4949
<ItemGroup>
5050
<ProjectReference Include="..\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj" />
5151
<ProjectReference Include="..\Microsoft.OpenApi\Microsoft.OpenApi.csproj" />
5252
</ItemGroup>
5353

54-
<ItemGroup>
55-
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
56-
</ItemGroup>
57-
5854
</Project>

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
3434
</PropertyGroup>
3535

36-
<ItemGroup>
37-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
38-
</ItemGroup>
39-
4036
<ItemGroup>
4137
<PackageReference Include="SharpYaml" Version="1.9.2" />
4238
</ItemGroup>

src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
88
</PropertyGroup>
99
<ItemGroup>
10-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
1110
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.3.330701">
1211
<PrivateAssets>all</PrivateAssets>
1312
</PackageReference>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System.Reflection;
5+
6+
namespace Microsoft.OpenApi.Any
7+
{
8+
/// <summary>
9+
/// Contains logic for cloning objects through copy constructors.
10+
/// </summary>
11+
public class OpenApiAnyCloneHelper
12+
{
13+
/// <summary>
14+
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
15+
/// </summary>
16+
/// <param name="obj">The object instance.</param>
17+
/// <returns>A clone copy or the object itself.</returns>
18+
public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
19+
{
20+
if (obj != null)
21+
{
22+
var t = obj.GetType();
23+
foreach (ConstructorInfo ci in t.GetConstructors())
24+
{
25+
ParameterInfo[] pi = ci.GetParameters();
26+
if (pi.Length == 1 && pi[0].ParameterType == t)
27+
{
28+
return (IOpenApiAny)ci.Invoke(new object[] { obj });
29+
}
30+
}
31+
}
32+
33+
return obj;
34+
}
35+
}
36+
}

src/Microsoft.OpenApi/Any/OpenApiArray.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
using Microsoft.OpenApi.Writers;
5+
using System;
56
using System.Collections.Generic;
67

78
namespace Microsoft.OpenApi.Any
@@ -16,6 +17,19 @@ public class OpenApiArray : List<IOpenApiAny>, IOpenApiAny
1617
/// </summary>
1718
public AnyType AnyType { get; } = AnyType.Array;
1819

20+
/// <summary>
21+
/// Parameterless constructor
22+
/// </summary>
23+
public OpenApiArray() { }
24+
25+
/// <summary>
26+
/// Initializes a copy of <see cref="OpenApiArray"/> object
27+
/// </summary>
28+
public OpenApiArray(OpenApiArray array)
29+
{
30+
AnyType = array.AnyType;
31+
}
32+
1933
/// <summary>
2034
/// Write out contents of OpenApiArray to passed writer
2135
/// </summary>

src/Microsoft.OpenApi/Any/OpenApiNull.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ public class OpenApiNull : IOpenApiAny
1515
/// </summary>
1616
public AnyType AnyType { get; } = AnyType.Null;
1717

18+
/// <summary>
19+
/// Parameterless constructor
20+
/// </summary>
21+
public OpenApiNull() { }
22+
23+
/// <summary>
24+
/// Initializes a copy of <see cref="OpenApiNull"/> object
25+
/// </summary>
26+
public OpenApiNull(OpenApiNull openApiNull)
27+
{
28+
AnyType = openApiNull.AnyType;
29+
}
30+
1831
/// <summary>
1932
/// Write out null representation
2033
/// </summary>

src/Microsoft.OpenApi/Any/OpenApiObject.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ public class OpenApiObject : Dictionary<string, IOpenApiAny>, IOpenApiAny
1616
/// </summary>
1717
public AnyType AnyType { get; } = AnyType.Object;
1818

19+
/// <summary>
20+
/// Parameterless constructor
21+
/// </summary>
22+
public OpenApiObject() { }
23+
24+
/// <summary>
25+
/// Initializes a copy of <see cref="OpenApiObject"/> object
26+
/// </summary>
27+
public OpenApiObject(OpenApiObject obj)
28+
{
29+
AnyType = obj.AnyType;
30+
}
31+
1932
/// <summary>
2033
/// Serialize OpenApiObject to writer
2134
/// </summary>

0 commit comments

Comments
 (0)