Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ffaf1d
Update ci-build.yml for Azure Pipelines
MaggieKimani1 May 11, 2022
b83b2cc
Bump Verify from 17.1.4 to 17.1.6
dependabot[bot] Jun 28, 2022
ce7a7f8
Merge pull request #918 from microsoft/dependabot/nuget/Verify-17.1.6
zengin Jun 29, 2022
bfac4a7
Bump Verify.Xunit from 17.1.4 to 17.1.6
dependabot[bot] Jun 29, 2022
a1f255c
Merge pull request #919 from microsoft/dependabot/nuget/Verify.Xunit-…
zengin Jun 29, 2022
673440e
remove explicit nuget reference to Verify
zengin Jun 29, 2022
a9ca6e9
Merge pull request #921 from microsoft/zengin/fix-verify-dependabot
zengin Jun 29, 2022
ddee0b2
Fixed reading v2 with path parameters that are form data
darrelmiller Jul 3, 2022
3dbe5d8
Fixed reading v2 with path parameter that is a body
darrelmiller Jul 4, 2022
ea83688
Update src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs
darrelmiller Jul 4, 2022
364952b
Update src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs
darrelmiller Jul 4, 2022
bbb6ae0
Update src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs
darrelmiller Jul 4, 2022
8d28c5a
Update src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs
darrelmiller Jul 4, 2022
d4b2c7b
- adds missing using for linq
baywet Jul 4, 2022
68f4ec0
Merge pull request #856 from microsoft/mk/update-release-task
darrelmiller Jul 4, 2022
05b9baf
Merge pull request #922 from microsoft/issues/885
darrelmiller Jul 4, 2022
b6b71b7
Bump Verify.Xunit from 17.1.6 to 17.2.1
dependabot[bot] Jul 4, 2022
45d7ab1
Added fix to handle case where produces or consumes is explicitly set…
darrelmiller Jul 4, 2022
8eed8cb
Merge pull request #925 from microsoft/dependabot/nuget/Verify.Xunit-…
zengin Jul 5, 2022
ccbf9eb
Updates csproj release notes to point to Github release notes
MaggieKimani1 Jul 6, 2022
99c384f
- releases hidi with discriminator fix
baywet Jul 6, 2022
1e83b74
- adds code owner configuration to the repository
baywet Jul 6, 2022
3a0a35b
Merge pull request #928 from microsoft/feature/hidi-release
baywet Jul 6, 2022
e3dbf99
Merge pull request #929 from microsoft/feature/codeowners
baywet Jul 6, 2022
5316794
Merge branch 'vnext' into mk/add-release-notes-pointer
baywet Jul 6, 2022
6cf6f51
- review suggestions
baywet Jul 6, 2022
404be88
Add a Github release notes link to csproj
MaggieKimani1 Jul 6, 2022
1ffc0bc
Merge remote-tracking branch 'origin/mk/add-release-notes-pointer' in…
MaggieKimani1 Jul 6, 2022
f07f345
Clean up
MaggieKimani1 Jul 6, 2022
a54ee5b
Merge pull request #926 from microsoft/issues/842
baywet Jul 6, 2022
521920d
Merge pull request #927 from microsoft/mk/add-release-notes-pointer
baywet Jul 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ stages:
nuGetFeedType: external
publishFeedCredentials: 'OpenAPI Nuget Connection'
- task: GitHubRelease@1
displayName: 'GitHub release (create)'
displayName: 'GitHub release (edit)'
inputs:
gitHubConnection: 'Github-MaggieKimani1'
tagSource: userSpecifiedTag
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @irvinesunday @darrelmiller @peombwa @zengin @baywet @millicentachieng @MaggieKimani1
10 changes: 3 additions & 7 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.0.0-preview6</Version>
<Version>1.0.0-preview7</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Bumps up the Microsoft.OpenAPI library to v1.3.2
- Bumps up the Microsoft.OData library to v7.12.0
- Bumps up the Microsoft.OpenApi.OData library to v1.0.11-preview3
</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.Hidi</AssemblyName>
<RootNamespace>Microsoft.OpenApi.Hidi</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand All @@ -47,7 +43,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.12.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview3" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.11-preview4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Fixed a bug where contact information would not read properly. #892
</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.Readers</AssemblyName>
<RootNamespace>Microsoft.OpenApi.Readers</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand Down
17 changes: 14 additions & 3 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,22 @@ internal static partial class OpenApiV2Deserializer
},
{
"consumes",
(o, n) => n.Context.SetTempStorage(TempStorageKeys.GlobalConsumes, n.CreateSimpleList(s => s.GetScalarValue()))
(o, n) => {
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
if (consumes.Count > 0)
{
n.Context.SetTempStorage(TempStorageKeys.GlobalConsumes, consumes);
}
}
},
{
"produces",
(o, n) => n.Context.SetTempStorage(TempStorageKeys.GlobalProduces, n.CreateSimpleList(s => s.GetScalarValue()))
"produces", (o, n) => {
var produces = n.CreateSimpleList(s => s.GetScalarValue());
if (produces.Count > 0)
{
n.Context.SetTempStorage(TempStorageKeys.GlobalProduces, produces);
}
}
},
{"paths", (o, n) => o.Paths = LoadPaths(n)},
{
Expand Down
18 changes: 12 additions & 6 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiOperationDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,20 @@ internal static partial class OpenApiV2Deserializer
}
},
{
"consumes", (o, n) => n.Context.SetTempStorage(
TempStorageKeys.OperationConsumes,
n.CreateSimpleList(s => s.GetScalarValue()))
"consumes", (o, n) => {
var consumes = n.CreateSimpleList(s => s.GetScalarValue());
if (consumes.Count > 0) {
n.Context.SetTempStorage(TempStorageKeys.OperationConsumes,consumes);
}
}
},
{
"produces", (o, n) => n.Context.SetTempStorage(
TempStorageKeys.OperationProduces,
n.CreateSimpleList(s => s.GetScalarValue()))
"produces", (o, n) => {
var produces = n.CreateSimpleList(s => s.GetScalarValue());
if (produces.Count > 0) {
n.Context.SetTempStorage(TempStorageKeys.OperationProduces, produces);
}
}
},
{
"responses", (o, n) =>
Expand Down
50 changes: 49 additions & 1 deletion src/Microsoft.OpenApi.Readers/V2/OpenApiPathItemDeserializer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.Collections.Generic;
using System.Linq;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Readers.ParseNodes;
Expand Down Expand Up @@ -32,7 +34,7 @@ internal static partial class OpenApiV2Deserializer
{
"parameters", (o, n) =>
{
o.Parameters = n.CreateList(LoadParameter);
LoadPathParameters(o,n);
}
},
};
Expand All @@ -53,5 +55,51 @@ public static OpenApiPathItem LoadPathItem(ParseNode node)

return pathItem;
}

private static void LoadPathParameters(OpenApiPathItem pathItem, ParseNode node)
{
node.Context.SetTempStorage(TempStorageKeys.BodyParameter, null);
node.Context.SetTempStorage(TempStorageKeys.FormParameters, null);

pathItem.Parameters = node.CreateList(LoadParameter);

// Build request body based on information determined while parsing OpenApiOperation
var bodyParameter = node.Context.GetFromTempStorage<OpenApiParameter>(TempStorageKeys.BodyParameter);
if (bodyParameter != null)
{
var requestBody = CreateRequestBody(node.Context, bodyParameter);
foreach(var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null))
{
switch (opPair.Key)
{
case OperationType.Post:
case OperationType.Put:
case OperationType.Patch:
opPair.Value.RequestBody = requestBody;
break;
}
}
}
else
{
var formParameters = node.Context.GetFromTempStorage<List<OpenApiParameter>>(TempStorageKeys.FormParameters);
if (formParameters != null)
{
var requestBody = CreateFormBody(node.Context, formParameters);
foreach (var opPair in pathItem.Operations.Where(x => x.Value.RequestBody is null))
{
switch (opPair.Key)
{
case OperationType.Post:
case OperationType.Put:
case OperationType.Patch:
opPair.Value.RequestBody = requestBody;
break;
}
}
}
}

}
}
}
4 changes: 1 addition & 3 deletions src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Adds support for c-style hex notation strings. #908
</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/microsoft/OpenAPI.NET/releases</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi</AssemblyName>
<RootNamespace>Microsoft.OpenApi</RootNamespace>
<SignAssembly>true</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
</PropertyGroup>
<ItemGroup>
<None Remove="V2Tests\Samples\ComponentRootReference.json" />
<None Remove="V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml" />
<None Remove="V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml" />
<None Remove="V3Tests\Samples\OpenApiWorkspace\TodoComponents.yaml" />
<None Remove="V3Tests\Samples\OpenApiWorkspace\TodoMain.yaml" />
</ItemGroup>
Expand Down Expand Up @@ -85,6 +87,12 @@
<EmbeddedResource Include="V2Tests\Samples\OpenApiParameter\queryParameter.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\pathItemWithFormDataPathParameter.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\pathItemWithBodyPathParameter.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiPathItem\basicPathItemWithFormData.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using FluentAssertions;
using Microsoft.OpenApi.Extensions;
Expand Down Expand Up @@ -253,10 +254,50 @@ public void ParseBasicPathItemWithFormDataShouldSucceed()
}

// Act
var operation = OpenApiV2Deserializer.LoadPathItem(node);
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);

// Assert
operation.Should().BeEquivalentTo(_basicPathItemWithFormData);
pathItem.Should().BeEquivalentTo(_basicPathItemWithFormData);
}

[Fact]
public void ParsePathItemWithFormDataPathParameterShouldSucceed()
{
// Arrange
MapNode node;
using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithFormDataPathParameter.yaml")))
{
node = TestHelper.CreateYamlMapNode(stream);
}

// Act
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);

// Assert
// FormData parameters at in the path level are pushed into Operation request bodies.
Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null);
Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null);
Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null));
}
[Fact]
public void ParsePathItemBodyDataPathParameterShouldSucceed()
{
// Arrange
MapNode node;
using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithBodyPathParameter.yaml")))
{
node = TestHelper.CreateYamlMapNode(stream);
}

// Act
var pathItem = OpenApiV2Deserializer.LoadPathItem(node);

// Assert
// FormData parameters at in the path level are pushed into Operation request bodies.
Assert.True(pathItem.Operations[OperationType.Put].RequestBody != null);
Assert.True(pathItem.Operations[OperationType.Post].RequestBody != null);
Assert.Equal(2, pathItem.Operations.Count(o => o.Value.RequestBody != null));
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
put:
summary: Puts a pet in the store with form data
description: ""
responses:
'200':
description: Pet updated.
'405':
description: Invalid input
post:
summary: Posts a pet in the store with form data
description: ""
responses:
'200':
description: Pet updated.
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: string
- name: name
in: body
description: Updated pet body
required: true
type: object
properties:
name:
type: string
status:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
put:
summary: Puts a pet in the store with form data
description: ""
responses:
'200':
description: Pet updated.
'405':
description: Invalid input
x-http-tests:
- parameterValues:
petId: 10
name: Milo
status: Happy
expectedRequest:
href: /pathitem-form-parameter/10
headers:
Content-Type: multipart/form-data
content: name=Milo&status=Happy
post:
summary: Posts a pet in the store with form data
description: ""
responses:
'200':
description: Pet updated.
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: string
- name: name
in: formData
description: Updated name of the pet
required: true
type: string
- name: status
in: formData
description: Updated status of the pet
required: false
type: string
3 changes: 1 addition & 2 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SharpYaml" Version="1.9.2" />
<PackageReference Include="Verify" Version="17.1.4" />
<PackageReference Include="Verify.Xunit" Version="17.1.4" />
<PackageReference Include="Verify.Xunit" Version="17.2.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down