Skip to content

Commit

Permalink
Merge pull request #1100 from microsoft/vnext
Browse files Browse the repository at this point in the history
1.4.5 release to unblock kiota
  • Loading branch information
baywet authored Dec 6, 2022
2 parents 40d67ac + 563b046 commit 0381437
Show file tree
Hide file tree
Showing 26 changed files with 906 additions and 47 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Sonarcloud
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore: ['.vscode/**']
pull_request:
types: [opened, synchronize, reopened]
paths-ignore: ['.vscode/**']

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

jobs:
checksecret:
name: check if SONAR_TOKEN is set in github secrets
runs-on: ubuntu-latest
outputs:
is_SONAR_TOKEN_set: ${{ steps.checksecret_job.outputs.is_SONAR_TOKEN_set }}
steps:
- name: Check whether unity activation requests should be done
id: checksecret_job
run: |
echo "is_SONAR_TOKEN_set=${{ env.SONAR_TOKEN != '' }}" >> $GITHUB_OUTPUT
build:
needs: [checksecret]
if: needs.checksecret.outputs.is_SONAR_TOKEN_set == 'true'
name: Build
runs-on: windows-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 11
- 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:
dotnet-version: 5.0.x
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ./.sonar/scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -Path ./.sonar/scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
CollectCoverage: true
CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
shell: pwsh
run: |
./.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"
dotnet workload restore
dotnet build
dotnet test Microsoft.OpenApi.sln --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Company>Microsoft</Company>
<Title>Microsoft.OpenApi.Readers</Title>
<PackageId>Microsoft.OpenApi.Readers</PackageId>
<Version>1.4.4</Version>
<Version>1.4.5</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
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.4.4</Version>
<Version>1.4.5</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
10 changes: 7 additions & 3 deletions src/Microsoft.OpenApi/Models/OpenApiParameter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using System.Runtime;
using Microsoft.OpenApi.Any;
Expand Down Expand Up @@ -238,9 +239,12 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer)

// allowEmptyValue
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);

// style
writer.WriteProperty(OpenApiConstants.Style, Style?.GetDisplayName());
if (_style.HasValue)
{
writer.WriteProperty(OpenApiConstants.Style, Style.Value.GetDisplayName());
}

// explode
writer.WriteProperty(OpenApiConstants.Explode, Explode, Style.HasValue && Style.Value == ParameterStyle.Form);
Expand Down Expand Up @@ -377,7 +381,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
// allowEmptyValue
writer.WriteProperty(OpenApiConstants.AllowEmptyValue, AllowEmptyValue, false);

if (this.In == ParameterLocation.Query)
if (this.In == ParameterLocation.Query && "array".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase))
{
if (this.Style == ParameterStyle.Form && this.Explode == true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Models/OpenApiSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public OpenApiSchema(OpenApiSchema schema)
MaxProperties = schema?.MaxProperties ?? MaxProperties;
MinProperties = schema?.MinProperties ?? MinProperties;
AdditionalPropertiesAllowed = schema?.AdditionalPropertiesAllowed ?? AdditionalPropertiesAllowed;
AdditionalProperties = new(schema?.AdditionalProperties);
AdditionalProperties = schema?.AdditionalProperties != null ? new(schema?.AdditionalProperties) : null;
Discriminator = schema?.Discriminator != null ? new(schema?.Discriminator) : null;
Example = OpenApiAnyCloneHelper.CloneFromCopyConstructor(schema?.Example);
Enum = schema?.Enum != null ? new List<IOpenApiAny>(schema.Enum) : null;
Expand Down
96 changes: 95 additions & 1 deletion src/Microsoft.OpenApi/Validations/OpenApiValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class OpenApiValidator : OpenApiVisitorBase, IValidationContext
private readonly IList<OpenApiValidatorWarning> _warnings = new List<OpenApiValidatorWarning>();

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

/// <summary>
/// Execute validation rules against a <see cref="OpenApiPathItem"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiPathItem item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiServerVariable"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiServerVariable item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiSecurityScheme"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiSecurityScheme item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiSecurityRequirement"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiSecurityRequirement item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiRequestBody"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiRequestBody item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiPaths"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiPaths item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiLink"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiLink item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiExample"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiExample item) => Validate(item);

/// <summary>
/// Execute validation rules against a <see cref="OpenApiOperation"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(OpenApiOperation item) => Validate(item);
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{OperationType, OpenApiOperation}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<OperationType, OpenApiOperation> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiHeader}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiHeader> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiCallback}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiCallback> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiMediaType}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiMediaType> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiExample}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiExample> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiLink}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiLink> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiServerVariable}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiServerVariable> item) => Validate(item, item.GetType());
/// <summary>
/// Execute validation rules against a <see cref="IDictionary{String, OpenApiEncoding}"/>
/// </summary>
/// <param name="item">The object to be validated</param>
public override void Visit(IDictionary<string, OpenApiEncoding> item) => Validate(item, item.GetType());

private void Validate<T>(T item)
{
var type = typeof(T);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="Moq" Version="4.18.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="FluentAssertions" Version="6.8.0">
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta2">
<PackageReference Include="Newtonsoft.Json" Version="13.0.2">
</PackageReference>
<PackageReference Include="SharpYaml" Version="2.1.0">
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
14 changes: 11 additions & 3 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Moq" Version="4.18.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="SharpYaml" Version="2.1.0" />
<PackageReference Include="Verify.Xunit" Version="19.1.0" />
<PackageReference Include="Verify.Xunit" Version="19.3.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"name": "limit",
"description": "maximum number of results to return",
"type": "integer",
"format": "int32",
"collectionFormat": "multi"
"format": "int32"
}
],
"responses": {
Expand Down
Loading

0 comments on commit 0381437

Please sign in to comment.