Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release libs #1324

Merged
merged 48 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8bfa0f3
Bump Verify.Xunit from 20.5.1 to 20.6.0
dependabot[bot] Jul 24, 2023
f1eacbd
Merge pull request #1298 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jul 24, 2023
b57ebbc
- bumps java version for sonarcloud to stay on supported version
baywet Aug 4, 2023
3573a7f
Bump Microsoft.NET.Test.Sdk from 17.6.3 to 17.7.0
dependabot[bot] Aug 4, 2023
52a6609
Merge pull request #1304 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Aug 4, 2023
107b0f0
Merge pull request #1303 from microsoft/feature/sonarcloud-java-version
baywet Aug 7, 2023
4af574c
Bump Moq from 4.18.4 to 4.20.1
dependabot[bot] Aug 8, 2023
a8c34da
Merge pull request #1305 from microsoft/dependabot/nuget/Moq-4.20.1
baywet Aug 8, 2023
f9e03d8
Bump Moq from 4.20.1 to 4.20.2
dependabot[bot] Aug 9, 2023
cfaad58
Merge pull request #1307 from microsoft/dependabot/nuget/Moq-4.20.2
baywet Aug 9, 2023
702908c
Bump Moq from 4.20.2 to 4.20.69
dependabot[bot] Aug 11, 2023
d9e7a9e
Merge pull request #1308 from microsoft/dependabot/nuget/Moq-4.20.69
baywet Aug 13, 2023
44def6a
Bump Verify.Xunit from 20.6.0 to 20.7.0
dependabot[bot] Aug 14, 2023
0070675
Merge pull request #1309 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Aug 14, 2023
15291ca
Bump Verify.Xunit from 20.7.0 to 20.8.0
dependabot[bot] Aug 15, 2023
3d8a671
Merge pull request #1310 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Aug 15, 2023
bbf77ed
Bump Microsoft.NET.Test.Sdk from 17.7.0 to 17.7.1
dependabot[bot] Aug 16, 2023
f2bf42e
Merge pull request #1313 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Aug 16, 2023
1349182
Create a media type object if produces is empty but a response schema…
MaggieKimani1 Aug 21, 2023
a53defa
Add a unit test for validation
MaggieKimani1 Aug 21, 2023
7ea74e1
Bump Verify.Xunit from 20.8.0 to 20.8.1
dependabot[bot] Aug 21, 2023
7b20280
Merge pull request #1317 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Aug 22, 2023
e9d3660
Default to application/octet-stream as the MIME type if produces is a…
MaggieKimani1 Aug 22, 2023
2ba6f70
Revert change; add a default value for produces when its null; remove…
MaggieKimani1 Aug 22, 2023
3636351
Update test
MaggieKimani1 Aug 22, 2023
6a7993e
Clean up test
MaggieKimani1 Aug 22, 2023
66c3e5c
Add test to verify request body schema is set when consumes is an emp…
MaggieKimani1 Aug 22, 2023
11d9f68
Revert previous fix
MaggieKimani1 Aug 22, 2023
5f90def
Use "application/octet-stream" as default MIME type if produces is an…
MaggieKimani1 Aug 22, 2023
9b91130
Combine two checks using TryGetValue() for efficiency
MaggieKimani1 Aug 22, 2023
68f2c22
Bump FluentAssertions from 6.11.0 to 6.12.0
dependabot[bot] Aug 23, 2023
fd50050
Merge pull request #1320 from microsoft/dependabot/nuget/FluentAssert…
baywet Aug 23, 2023
a55d4a6
Bump Verify.Xunit from 20.8.1 to 20.8.2
dependabot[bot] Aug 28, 2023
f98eb7e
Merge pull request #1321 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Aug 29, 2023
e924d19
Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2
dependabot[bot] Aug 29, 2023
5b08061
Merge pull request #1322 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Aug 29, 2023
589944d
Merge remote-tracking branch 'origin/vnext' into mk/integrate-json-sc…
MaggieKimani1 Aug 30, 2023
dc319ec
Only set produces if it contains a value
MaggieKimani1 Aug 30, 2023
845f314
Refactor and clean up code
MaggieKimani1 Aug 30, 2023
4e81bf9
Maintain ordering of properties as specified in fixedFieldMap by doin…
MaggieKimani1 Aug 30, 2023
ab9648c
Remove unused private method
MaggieKimani1 Aug 30, 2023
e666d3d
Add null conditional operator
MaggieKimani1 Aug 31, 2023
966b459
Use Assert.Fail() to fail the test
MaggieKimani1 Aug 31, 2023
a83f01a
Use static keyword; fix sonarcloud bug
MaggieKimani1 Aug 31, 2023
201e90e
Update langVersion to latest
MaggieKimani1 Aug 31, 2023
c377232
Merge pull request #1316 from microsoft/mk/fix-missing-response-schem…
MaggieKimani1 Aug 31, 2023
a379f1b
Bump up lib versions
MaggieKimani1 Aug 31, 2023
c022557
Merge pull request #1323 from microsoft/mk/upgrade-versions
MaggieKimani1 Aug 31, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
name: Build
runs-on: windows-latest
steps:
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
java-version: 17
- name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner
uses: actions/setup-dotnet@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.2.6</Version>
<Version>1.2.7</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageIconUrl>http://go.microsoft.com/fwlink/?LinkID=288890</PackageIconUrl>
<PackageProjectUrl>https://github.com/Microsoft/OpenAPI.NET</PackageProjectUrl>
Expand All @@ -10,7 +11,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi.Readers</Title>
<PackageId>Microsoft.OpenApi.Readers</PackageId>
<Version>1.6.6</Version>
<Version>1.6.7</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
42 changes: 21 additions & 21 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,35 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P
}

var produces = context.GetFromTempStorage<List<string>>(TempStorageKeys.OperationProduces)
?? context.GetFromTempStorage<List<string>>(TempStorageKeys.GlobalProduces);
if (produces != null)
?? context.GetFromTempStorage<List<string>>(TempStorageKeys.GlobalProduces)
?? new List<string> { "application/octet-stream" };

var schema = context.GetFromTempStorage<OpenApiSchema>(TempStorageKeys.ResponseSchema, response);

foreach (var produce in produces)
{
foreach (var produce in produces)
{
var schema = context.GetFromTempStorage<OpenApiSchema>(TempStorageKeys.ResponseSchema, response);

if (response.Content.ContainsKey(produce) && response.Content[produce] != null)
if (response.Content.TryGetValue(produce, out var produceValue))
{
if (schema != null)
{
if (schema != null)
{
response.Content[produce].Schema = schema;
ProcessAnyFields(mapNode, response.Content[produce], _mediaTypeAnyFields);
}
produceValue.Schema = schema;
ProcessAnyFields(mapNode, produceValue, _mediaTypeAnyFields);
}
else
}
else
{
var mediaType = new OpenApiMediaType
{
var mediaType = new OpenApiMediaType
{
Schema = schema
};
Schema = schema
};

response.Content.Add(produce, mediaType);
}
response.Content.Add(produce, mediaType);
}

context.SetTempStorage(TempStorageKeys.ResponseSchema, null, response);
context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response);
}

context.SetTempStorage(TempStorageKeys.ResponseSchema, null, response);
context.SetTempStorage(TempStorageKeys.ResponseProducesSet, true, response);
}

private static void LoadExamples(OpenApiResponse response, ParseNode node)
Expand Down
68 changes: 15 additions & 53 deletions src/Microsoft.OpenApi.Readers/V2/OpenApiV2Deserializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.Collections.Generic;
Expand Down Expand Up @@ -29,10 +29,11 @@ private static void ParseMap<T>(
return;
}

foreach (var propertyNode in mapNode)
var allFields = fixedFieldMap.Keys.Union(mapNode.Select(static x => x.Name));
foreach (var propertyNode in allFields)
{
propertyNode.ParseField(domainObject, fixedFieldMap, patternFieldMap);
requiredFields?.Remove(propertyNode.Name);
mapNode[propertyNode]?.ParseField(domainObject, fixedFieldMap, patternFieldMap);
requiredFields?.Remove(propertyNode);
}
}

Expand Down Expand Up @@ -77,16 +78,18 @@ private static void ProcessAnyListFields<T>(
var newProperty = new List<IOpenApiAny>();

mapNode.Context.StartObject(anyListFieldName);

var list = anyListFieldMap[anyListFieldName].PropertyGetter(domainObject);
if (list != null)
if (anyListFieldMap.TryGetValue(anyListFieldName, out var fieldName))
{
foreach (var propertyElement in list)
var list = fieldName.PropertyGetter(domainObject);
if (list != null)
{
newProperty.Add(
OpenApiAnyConverter.GetSpecificOpenApiAny(
propertyElement,
anyListFieldMap[anyListFieldName].SchemaGetter(domainObject)));
foreach (var propertyElement in list)
{
newProperty.Add(
OpenApiAnyConverter.GetSpecificOpenApiAny(
propertyElement,
anyListFieldMap[anyListFieldName].SchemaGetter(domainObject)));
}
}
}

Expand All @@ -104,47 +107,6 @@ private static void ProcessAnyListFields<T>(
}
}

private static void ProcessAnyMapFields<T, U>(
MapNode mapNode,
T domainObject,
AnyMapFieldMap<T, U> anyMapFieldMap)
{
foreach (var anyMapFieldName in anyMapFieldMap.Keys.ToList())
{
try
{
var newProperty = new List<IOpenApiAny>();

mapNode.Context.StartObject(anyMapFieldName);

foreach (var propertyMapElement in anyMapFieldMap[anyMapFieldName].PropertyMapGetter(domainObject))
{
if (propertyMapElement.Value != null)
{
mapNode.Context.StartObject(propertyMapElement.Key);

var any = anyMapFieldMap[anyMapFieldName].PropertyGetter(propertyMapElement.Value);

var newAny = OpenApiAnyConverter.GetSpecificOpenApiAny(
any,
anyMapFieldMap[anyMapFieldName].SchemaGetter(domainObject));

anyMapFieldMap[anyMapFieldName].PropertySetter(propertyMapElement.Value, newAny);
}
}
}
catch (OpenApiException exception)
{
exception.Pointer = mapNode.Context.GetLocation();
mapNode.Context.Diagnostic.Errors.Add(new OpenApiError(exception));
}
finally
{
mapNode.Context.EndObject();
}
}
}

public static IOpenApiAny LoadAny(ParseNode node)
{
return OpenApiAnyConverter.GetSpecificOpenApiAny(node.CreateAny());
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Microsoft.OpenApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi</Title>
<PackageId>Microsoft.OpenApi</PackageId>
<Version>1.6.6</Version>
<Version>1.6.7</Version>
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private void ResolveTags(IList<OpenApiTag> tags)

private T ResolveReference<T>(OpenApiReference reference) where T : class, IOpenApiReferenceable, new()
{
if (string.IsNullOrEmpty(reference.ExternalResource))
if (string.IsNullOrEmpty(reference?.ExternalResource))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand Down Expand Up @@ -51,10 +51,14 @@
<EmbeddedResource Include="V2Tests\Samples\OpenApiOperation\operationWithBody.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiOperation\operationWithBodyAndEmptyConsumes.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiOperation\operationWithFormData.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="V2Tests\Samples\OpenApiOperation\operationWithResponseExamples.yaml" />
<EmbeddedResource Include="V2Tests\Samples\OpenApiOperation\operationWithEmptyProducesArrayInResponse.json" />
<EmbeddedResource Include="V2Tests\Samples\OpenApiParameter\bodyParameter.yaml">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
Expand Down Expand Up @@ -268,8 +272,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="FluentAssertions" Version="6.11.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0">
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,45 +163,25 @@ public void ShouldParseProducesInAnyOrder()
var reader = new OpenApiStreamReader();
var doc = reader.Read(stream, out var diagnostic);

var successSchema = new OpenApiSchema()
var okSchema = new OpenApiSchema()
{
Type = "array",
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Item",
HostDocument = doc
},
Items = new OpenApiSchema()
Properties = new Dictionary<string, OpenApiSchema>()
{
Reference = new OpenApiReference()
{
Type = ReferenceType.Schema,
Id = "Item",
HostDocument = doc
{ "id", new OpenApiSchema()
{
Type = "string",
Description = "Item identifier."
}
}
}
};

var okSchema = new OpenApiSchema()
{
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Item",
HostDocument = doc
},
Properties = new Dictionary<string, OpenApiSchema>()
{
{ "id", new OpenApiSchema()
{
Type = "string",
Description = "Item identifier."
}
}
}
};

var errorSchema = new OpenApiSchema()
{
Reference = new OpenApiReference
Expand All @@ -211,24 +191,24 @@ public void ShouldParseProducesInAnyOrder()
HostDocument = doc
},
Properties = new Dictionary<string, OpenApiSchema>()
{
{ "code", new OpenApiSchema()
{
Type = "integer",
Format = "int32"
}
},
{ "message", new OpenApiSchema()
{
Type = "string"
}
},
{ "fields", new OpenApiSchema()
{
Type = "string"
}
}
}
{
{ "code", new OpenApiSchema()
{
Type = "integer",
Format = "int32"
}
},
{ "message", new OpenApiSchema()
{
Type = "string"
}
},
{ "fields", new OpenApiSchema()
{
Type = "string"
}
}
}
};

var okMediaType = new OpenApiMediaType
Expand Down Expand Up @@ -439,7 +419,7 @@ public void ShouldAllowComponentsThatJustContainAReference()
if (schema2.UnresolvedReference && schema1.Reference.Id == schema2.Reference.Id)
{
// detected a cycle - this code gets triggered
Assert.True(false, "A cycle should not be detected");
Assert.Fail("A cycle should not be detected");
}
}
}
Expand Down
Loading