Skip to content

Commit 6cf490e

Browse files
authored
Merge pull request #931 from microsoft/vnext
releases hidi
2 parents 98877ba + 521920d commit 6cf490e

File tree

13 files changed

+206
-28
lines changed

13 files changed

+206
-28
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ stages:
287287
nuGetFeedType: external
288288
publishFeedCredentials: 'OpenAPI Nuget Connection'
289289
- task: GitHubRelease@1
290-
displayName: 'GitHub release (create)'
290+
displayName: 'GitHub release (edit)'
291291
inputs:
292292
gitHubConnection: 'Github-MaggieKimani1'
293293
tagSource: userSpecifiedTag

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @irvinesunday @darrelmiller @peombwa @zengin @baywet @millicentachieng @MaggieKimani1

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
1616
<ToolCommandName>hidi</ToolCommandName>
1717
<PackageOutputPath>./../../artifacts</PackageOutputPath>
18-
<Version>1.0.0-preview6</Version>
18+
<Version>1.0.0-preview7</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>
2222
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
23-
<PackageReleaseNotes>
24-
- Bumps up the Microsoft.OpenAPI library to v1.3.2
25-
- Bumps up the Microsoft.OData library to v7.12.0
26-
- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview3
27-
</PackageReleaseNotes>
23+
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
2824
<AssemblyName>Microsoft.OpenApi.Hidi</AssemblyName>
2925
<RootNamespace>Microsoft.OpenApi.Hidi</RootNamespace>
3026
<SignAssembly>true</SignAssembly>
@@ -47,7 +43,7 @@
4743
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
4844
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
4945
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.0" />
50-
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview3" />
46+
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview4" />
5147
</ItemGroup>
5248

5349
<ItemGroup>

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>
1717
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
18-
<PackageReleaseNotes>
19-
- Fixed a bug where contact information would not read properly. #892
20-
</PackageReleaseNotes>
18+
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
2119
<AssemblyName>Microsoft.OpenApi.Readers</AssemblyName>
2220
<RootNamespace>Microsoft.OpenApi.Readers</RootNamespace>
2321
<SignAssembly>true</SignAssembly>

src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,22 @@ internal static partial class OpenApiV2Deserializer
3636
},
3737
{
3838
"consumes",
39-
(o, n) => n.Context.SetTempStorage(TempStorageKeys.GlobalConsumes, n.CreateSimpleList(s => s.GetScalarValue()))
39+
(o, n) => {
40+
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
41+
if (consumes.Count > 0)
42+
{
43+
n.Context.SetTempStorage(TempStorageKeys.GlobalConsumes, consumes);
44+
}
45+
}
4046
},
4147
{
42-
"produces",
43-
(o, n) => n.Context.SetTempStorage(TempStorageKeys.GlobalProduces, n.CreateSimpleList(s => s.GetScalarValue()))
48+
"produces", (o, n) => {
49+
var produces = n.CreateSimpleList(s => s.GetScalarValue());
50+
if (produces.Count > 0)
51+
{
52+
n.Context.SetTempStorage(TempStorageKeys.GlobalProduces, produces);
53+
}
54+
}
4455
},
4556
{"paths", (o, n) => o.Paths = LoadPaths(n)},
4657
{

src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,20 @@ internal static partial class OpenApiV2Deserializer
5757
}
5858
},
5959
{
60-
"consumes", (o, n) => n.Context.SetTempStorage(
61-
TempStorageKeys.OperationConsumes,
62-
n.CreateSimpleList(s => s.GetScalarValue()))
60+
"consumes", (o, n) => {
61+
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
62+
if (consumes.Count > 0) {
63+
n.Context.SetTempStorage(TempStorageKeys.OperationConsumes,consumes);
64+
}
65+
}
6366
},
6467
{
65-
"produces", (o, n) => n.Context.SetTempStorage(
66-
TempStorageKeys.OperationProduces,
67-
n.CreateSimpleList(s => s.GetScalarValue()))
68+
"produces", (o, n) => {
69+
var produces = n.CreateSimpleList(s => s.GetScalarValue());
70+
if (produces.Count > 0) {
71+
n.Context.SetTempStorage(TempStorageKeys.OperationProduces, produces);
72+
}
73+
}
6874
},
6975
{
7076
"responses", (o, n) =>

src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs

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

4+
using System.Collections.Generic;
5+
using System.Linq;
46
using Microsoft.OpenApi.Extensions;
57
using Microsoft.OpenApi.Models;
68
using Microsoft.OpenApi.Readers.ParseNodes;
@@ -32,7 +34,7 @@ internal static partial class OpenApiV2Deserializer
3234
{
3335
"parameters", (o, n) =>
3436
{
35-
o.Parameters = n.CreateList(LoadParameter);
37+
LoadPathParameters(o,n);
3638
}
3739
},
3840
};
@@ -53,5 +55,51 @@ public static OpenApiPathItem LoadPathItem(ParseNode node)
5355

5456
return pathItem;
5557
}
58+
59+
private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node)
60+
{
61+
node.Context.SetTempStorage(TempStorageKeys.BodyParameter, null);
62+
node.Context.SetTempStorage(TempStorageKeys.FormParameters, null);
63+
64+
pathItem.Parameters = node.CreateList(LoadParameter);
65+
66+
// Build request body based on information determined while parsing OpenApiOperation
67+
var bodyParameter = node.Context.GetFromTempStorage<OpenApiParameter>(TempStorageKeys.BodyParameter);
68+
if (bodyParameter != null)
69+
{
70+
var requestBody = CreateRequestBody(node.Context, bodyParameter);
71+
foreach(var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null))
72+
{
73+
switch (opPair.Key)
74+
{
75+
case OperationType.Post:
76+
case OperationType.Put:
77+
case OperationType.Patch:
78+
opPair.Value.RequestBody = requestBody;
79+
break;
80+
}
81+
}
82+
}
83+
else
84+
{
85+
var formParameters = node.Context.GetFromTempStorage<List<OpenApiParameter>>(TempStorageKeys.FormParameters);
86+
if (formParameters != null)
87+
{
88+
var requestBody = CreateFormBody(node.Context, formParameters);
89+
foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null))
90+
{
91+
switch (opPair.Key)
92+
{
93+
case OperationType.Post:
94+
case OperationType.Put:
95+
case OperationType.Patch:
96+
opPair.Value.RequestBody = requestBody;
97+
break;
98+
}
99+
}
100+
}
101+
}
102+
103+
}
56104
}
57105
}

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1717
<PackageTags>OpenAPI .NET</PackageTags>
1818
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
19-
<PackageReleaseNotes>
20-
- Adds support for c-style hex notation strings. #908
21-
</PackageReleaseNotes>
19+
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
2220
<AssemblyName>Microsoft.OpenApi</AssemblyName>
2321
<RootNamespace>Microsoft.OpenApi</RootNamespace>
2422
<SignAssembly>true</SignAssembly>

test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
</PropertyGroup>
1515
<ItemGroup>
1616
<None Remove="V2Tests\Samples\ComponentRootReference.json" />
17+
<None Remove="V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml" />
18+
<None Remove="V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml" />
1719
<None Remove="V3Tests\Samples\OpenApiWorkspace\TodoComponents.yaml" />
1820
<None Remove="V3Tests\Samples\OpenApiWorkspace\TodoMain.yaml" />
1921
</ItemGroup>
@@ -85,6 +87,12 @@
8587
<EmbeddedResource Include="V2Tests\Samples\OpenApiParameter\queryParameter.yaml">
8688
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
8789
</EmbeddedResource>
90+
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml">
91+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
92+
</EmbeddedResource>
93+
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml">
94+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
95+
</EmbeddedResource>
8896
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\basicPathItemWithFormData.yaml">
8997
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
9098
</EmbeddedResource>

test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67
using System.Text;
78
using FluentAssertions;
89
using Microsoft.OpenApi.Extensions;
@@ -253,10 +254,50 @@ public void ParseBasicPathItemWithFormDataShouldSucceed()
253254
}
254255

255256
// Act
256-
var operation = OpenApiV2Deserializer.LoadPathItem(node);
257+
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);
257258

258259
// Assert
259-
operation.Should().BeEquivalentTo(_basicPathItemWithFormData);
260+
pathItem.Should().BeEquivalentTo(_basicPathItemWithFormData);
260261
}
262+
263+
[Fact]
264+
public void ParsePathItemWithFormDataPathParameterShouldSucceed()
265+
{
266+
// Arrange
267+
MapNode node;
268+
using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithFormDataPathParameter.yaml")))
269+
{
270+
node = TestHelper.CreateYamlMapNode(stream);
271+
}
272+
273+
// Act
274+
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);
275+
276+
// Assert
277+
// FormData parameters at in the path level are pushed into Operation request bodies.
278+
Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null);
279+
Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null);
280+
Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null));
281+
}
282+
[Fact]
283+
public void ParsePathItemBodyDataPathParameterShouldSucceed()
284+
{
285+
// Arrange
286+
MapNode node;
287+
using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithBodyPathParameter.yaml")))
288+
{
289+
node = TestHelper.CreateYamlMapNode(stream);
290+
}
291+
292+
// Act
293+
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);
294+
295+
// Assert
296+
// FormData parameters at in the path level are pushed into Operation request bodies.
297+
Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null);
298+
Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null);
299+
Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null));
300+
}
301+
261302
}
262303
}

0 commit comments

Comments
 (0)