Skip to content

Commit 0381437

Browse files
authored
Merge pull request #1100 from microsoft/vnext
1.4.5 release to unblock kiota
2 parents 40d67ac + 563b046 commit 0381437

File tree

26 files changed

+906
-47
lines changed

26 files changed

+906
-47
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Sonarcloud
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore: ['.vscode/**']
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
paths-ignore: ['.vscode/**']
11+
12+
env:
13+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14+
15+
jobs:
16+
checksecret:
17+
name: check if SONAR_TOKEN is set in github secrets
18+
runs-on: ubuntu-latest
19+
outputs:
20+
is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }}
21+
steps:
22+
- name: Check whether unity activation requests should be done
23+
id: checksecret_job
24+
run: |
25+
echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT
26+
build:
27+
needs: [checksecret]
28+
if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true'
29+
name: Build
30+
runs-on: windows-latest
31+
steps:
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: 'adopt'
36+
java-version: 11
37+
- name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner
38+
uses: actions/setup-dotnet@v3
39+
with:
40+
dotnet-version: 5.0.x
41+
- name: Setup .NET
42+
uses: actions/setup-dotnet@v3
43+
with:
44+
dotnet-version: 7.0.x
45+
- uses: actions/checkout@v3
46+
with:
47+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
48+
- name: Cache SonarCloud packages
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.sonar/cache
52+
key: ${{ runner.os }}-sonar
53+
restore-keys: ${{ runner.os }}-sonar
54+
- name: Cache SonarCloud scanner
55+
id: cache-sonar-scanner
56+
uses: actions/cache@v3
57+
with:
58+
path: ./.sonar/scanner
59+
key: ${{ runner.os }}-sonar-scanner
60+
restore-keys: ${{ runner.os }}-sonar-scanner
61+
- name: Install SonarCloud scanner
62+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
63+
shell: pwsh
64+
run: |
65+
New-Item -Path ./.sonar/scanner -ItemType Directory
66+
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
67+
- name: Build and analyze
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
70+
CollectCoverage: true
71+
CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
72+
shell: pwsh
73+
run: |
74+
./.sonar/scanner/dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET" /o:"microsoft" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml"
75+
dotnet workload restore
76+
dotnet build
77+
dotnet test Microsoft.OpenApi.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
78+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.4.4</Version>
13+
<Version>1.4.5</Version>
1414
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi/Microsoft.OpenApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Company>Microsoft</Company>
1212
<Title>Microsoft.OpenApi</Title>
1313
<PackageId>Microsoft.OpenApi</PackageId>
14-
<Version>1.4.4</Version>
14+
<Version>1.4.5</Version>
1515
<Description>.NET models with JSON and YAML writers for OpenAPI specification</Description>
1616
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1717
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi/Models/OpenApiParameter.cs

Lines changed: 7 additions & 3 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;
45
using System.Collections.Generic;
56
using System.Runtime;
67
using Microsoft.OpenApi.Any;
@@ -238,9 +239,12 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)
238239

239240
// allowEmptyValue
240241
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
241-
242+
242243
// style
243-
writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
244+
if (_style.HasValue)
245+
{
246+
writer.WriteProperty(OpenApiConstants.Style, Style.Value.GetDisplayName());
247+
}
244248

245249
// explode
246250
writer.WriteProperty(OpenApiConstants.Explode, Explode, Style.HasValue && Style.Value == ParameterStyle.Form);
@@ -377,7 +381,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
377381
// allowEmptyValue
378382
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);
379383

380-
if (this.In == ParameterLocation.Query)
384+
if (this.In == ParameterLocation.Query && "array".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase))
381385
{
382386
if (this.Style == ParameterStyle.Form && this.Explode == true)
383387
{

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public OpenApiSchema(OpenApiSchema schema)
280280
MaxProperties = schema?.MaxProperties ?? MaxProperties;
281281
MinProperties = schema?.MinProperties ?? MinProperties;
282282
AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
283-
AdditionalProperties = new(schema?.AdditionalProperties);
283+
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
284284
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
285285
Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Example);
286286
Enum = schema?.Enum != null ? new List<IOpenApiAny>(schema.Enum) : null;

src/Microsoft.OpenApi/Validations/OpenApiValidator.cs

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class OpenApiValidator : OpenApiVisitorBase, IValidationContext
2020
private readonly IList<OpenApiValidatorWarning> _warnings = new List<OpenApiValidatorWarning>();
2121

2222
/// <summary>
23-
/// Create a vistor that will validate an OpenAPIDocument
23+
/// Create a visitor that will validate an OpenAPIDocument
2424
/// </summary>
2525
/// <param name="ruleSet"></param>
2626
public OpenApiValidator(ValidationRuleSet ruleSet)
@@ -198,6 +198,100 @@ public void AddWarning(OpenApiValidatorWarning warning)
198198
/// <param name="items">The object to be validated</param>
199199
public override void Visit(IList<OpenApiExample> items) => Validate(items, items.GetType());
200200

201+
/// <summary>
202+
/// Execute validation rules against a <see cref="OpenApiPathItem"/>
203+
/// </summary>
204+
/// <param name="item">The object to be validated</param>
205+
public override void Visit(OpenApiPathItem item) => Validate(item);
206+
207+
/// <summary>
208+
/// Execute validation rules against a <see cref="OpenApiServerVariable"/>
209+
/// </summary>
210+
/// <param name="item">The object to be validated</param>
211+
public override void Visit(OpenApiServerVariable item) => Validate(item);
212+
213+
/// <summary>
214+
/// Execute validation rules against a <see cref="OpenApiSecurityScheme"/>
215+
/// </summary>
216+
/// <param name="item">The object to be validated</param>
217+
public override void Visit(OpenApiSecurityScheme item) => Validate(item);
218+
219+
/// <summary>
220+
/// Execute validation rules against a <see cref="OpenApiSecurityRequirement"/>
221+
/// </summary>
222+
/// <param name="item">The object to be validated</param>
223+
public override void Visit(OpenApiSecurityRequirement item) => Validate(item);
224+
225+
/// <summary>
226+
/// Execute validation rules against a <see cref="OpenApiRequestBody"/>
227+
/// </summary>
228+
/// <param name="item">The object to be validated</param>
229+
public override void Visit(OpenApiRequestBody item) => Validate(item);
230+
231+
/// <summary>
232+
/// Execute validation rules against a <see cref="OpenApiPaths"/>
233+
/// </summary>
234+
/// <param name="item">The object to be validated</param>
235+
public override void Visit(OpenApiPaths item) => Validate(item);
236+
237+
/// <summary>
238+
/// Execute validation rules against a <see cref="OpenApiLink"/>
239+
/// </summary>
240+
/// <param name="item">The object to be validated</param>
241+
public override void Visit(OpenApiLink item) => Validate(item);
242+
243+
/// <summary>
244+
/// Execute validation rules against a <see cref="OpenApiExample"/>
245+
/// </summary>
246+
/// <param name="item">The object to be validated</param>
247+
public override void Visit(OpenApiExample item) => Validate(item);
248+
249+
/// <summary>
250+
/// Execute validation rules against a <see cref="OpenApiOperation"/>
251+
/// </summary>
252+
/// <param name="item">The object to be validated</param>
253+
public override void Visit(OpenApiOperation item) => Validate(item);
254+
/// <summary>
255+
/// Execute validation rules against a <see cref="IDictionary{OperationType, OpenApiOperation}"/>
256+
/// </summary>
257+
/// <param name="item">The object to be validated</param>
258+
public override void Visit(IDictionary<OperationType, OpenApiOperation> item) => Validate(item, item.GetType());
259+
/// <summary>
260+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiHeader}"/>
261+
/// </summary>
262+
/// <param name="item">The object to be validated</param>
263+
public override void Visit(IDictionary<string, OpenApiHeader> item) => Validate(item, item.GetType());
264+
/// <summary>
265+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiCallback}"/>
266+
/// </summary>
267+
/// <param name="item">The object to be validated</param>
268+
public override void Visit(IDictionary<string, OpenApiCallback> item) => Validate(item, item.GetType());
269+
/// <summary>
270+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiMediaType}"/>
271+
/// </summary>
272+
/// <param name="item">The object to be validated</param>
273+
public override void Visit(IDictionary<string, OpenApiMediaType> item) => Validate(item, item.GetType());
274+
/// <summary>
275+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiExample}"/>
276+
/// </summary>
277+
/// <param name="item">The object to be validated</param>
278+
public override void Visit(IDictionary<string, OpenApiExample> item) => Validate(item, item.GetType());
279+
/// <summary>
280+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiLink}"/>
281+
/// </summary>
282+
/// <param name="item">The object to be validated</param>
283+
public override void Visit(IDictionary<string, OpenApiLink> item) => Validate(item, item.GetType());
284+
/// <summary>
285+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiServerVariable}"/>
286+
/// </summary>
287+
/// <param name="item">The object to be validated</param>
288+
public override void Visit(IDictionary<string, OpenApiServerVariable> item) => Validate(item, item.GetType());
289+
/// <summary>
290+
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiEncoding}"/>
291+
/// </summary>
292+
/// <param name="item">The object to be validated</param>
293+
public override void Visit(IDictionary<string, OpenApiEncoding> item) => Validate(item, item.GetType());
294+
201295
private void Validate<T>(T item)
202296
{
203297
var type = typeof(T);

test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
14+
<PrivateAssets>all</PrivateAssets>
15+
</PackageReference>
1216
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
13-
<PackageReference Include="Moq" Version="4.18.2" />
17+
<PackageReference Include="Moq" Version="4.18.3" />
1418
<PackageReference Include="xunit" Version="2.4.2" />
1519
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1620
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,18 @@
253253
</ItemGroup>
254254

255255
<ItemGroup>
256+
<PackageReference Include="coverlet.collector" Version="3.2.0">
257+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
258+
<PrivateAssets>all</PrivateAssets>
259+
</PackageReference>
260+
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
261+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
262+
<PrivateAssets>all</PrivateAssets>
263+
</PackageReference>
256264
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
257265
<PackageReference Include="FluentAssertions" Version="6.8.0">
258266
</PackageReference>
259-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta2">
267+
<PackageReference Include="Newtonsoft.Json" Version="13.0.2">
260268
</PackageReference>
261269
<PackageReference Include="SharpYaml" Version="2.1.0">
262270
</PackageReference>

test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<PackageReference Include="coverlet.collector" Version="3.2.0">
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
<PrivateAssets>all</PrivateAssets>
14+
</PackageReference>
15+
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
<PrivateAssets>all</PrivateAssets>
18+
</PackageReference>
1119
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
12-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta2" />
20+
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
1321
<PackageReference Include="xunit" Version="2.4.2" />
1422
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1523
<PrivateAssets>all</PrivateAssets>

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18+
<PackageReference Include="coverlet.collector" Version="3.2.0">
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
<PrivateAssets>all</PrivateAssets>
21+
</PackageReference>
22+
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
<PrivateAssets>all</PrivateAssets>
25+
</PackageReference>
1826
<PackageReference Include="FluentAssertions" Version="6.8.0" />
1927
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
20-
<PackageReference Include="Moq" Version="4.18.2" />
21-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
28+
<PackageReference Include="Moq" Version="4.18.3" />
29+
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
2230
<PackageReference Include="SharpYaml" Version="2.1.0" />
23-
<PackageReference Include="Verify.Xunit" Version="19.1.0" />
31+
<PackageReference Include="Verify.Xunit" Version="19.3.0" />
2432
<PackageReference Include="xunit" Version="2.4.2" />
2533
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2634
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)