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

1.4.5 release to unblock kiota #1100

Merged
merged 39 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7c9fac2
Add condition to ensure collectionFormat is only written out if schem…
MaggieKimani1 Nov 22, 2022
42a4015
Add test
MaggieKimani1 Nov 22, 2022
a409b31
Update verify snapshots
MaggieKimani1 Nov 22, 2022
257107c
Address PR feedback
MaggieKimani1 Nov 22, 2022
ef5bcf6
Merge pull request #1088 from microsoft/mk/fix-unexpected-collection-…
MaggieKimani1 Nov 22, 2022
bf9a481
Use backing property to check whether user has explicitly set style, …
MaggieKimani1 Nov 23, 2022
3eb4f02
Add test to validate
MaggieKimani1 Nov 23, 2022
9681ebb
Clean up tests
MaggieKimani1 Nov 23, 2022
1b7df17
Merge branch 'vnext' into mk/fix-null-style-parameter-issue
MaggieKimani1 Nov 23, 2022
48394ef
Update verifier snapshot
MaggieKimani1 Nov 23, 2022
b43561b
Merge remote-tracking branch 'origin/mk/fix-null-style-parameter-issu…
MaggieKimani1 Nov 23, 2022
0a0ec5f
Delete verifier
MaggieKimani1 Nov 23, 2022
089ddc2
Revert change
MaggieKimani1 Nov 23, 2022
429d7c5
Bump Newtonsoft.Json from 13.0.1 to 13.0.2 (#1091)
dependabot[bot] Nov 25, 2022
49270e3
Remove test
MaggieKimani1 Nov 25, 2022
775c136
Remove verified text
MaggieKimani1 Nov 25, 2022
b47d3a1
Add verified text
MaggieKimani1 Nov 25, 2022
2a7cfdc
Return test
MaggieKimani1 Nov 25, 2022
4df2357
Delete verified text
MaggieKimani1 Nov 25, 2022
d41d2af
Add verified text
MaggieKimani1 Nov 25, 2022
84a7ba2
Revert change
MaggieKimani1 Nov 25, 2022
0527f99
Remove static modifier as it creates static dependency of the documen…
MaggieKimani1 Nov 28, 2022
d4b6c00
Update verified snapshots
MaggieKimani1 Nov 28, 2022
8bc957d
Merge pull request #1090 from microsoft/mk/fix-null-style-parameter-i…
MaggieKimani1 Nov 28, 2022
5a58d79
- adds coverage dependencies
baywet Nov 29, 2022
47984b4
- adds sonarcloud workflow definition
baywet Nov 29, 2022
65e92bf
- switches to windows agent because of workbench projectg
baywet Nov 29, 2022
53f5f80
Bump Verify.Xunit from 19.1.0 to 19.3.0
dependabot[bot] Nov 29, 2022
7144013
Merge pull request #1093 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Nov 29, 2022
f8678d3
- adds missing validation methods
baywet Dec 5, 2022
2d9a007
- reorders public api definition
baywet Dec 5, 2022
9d5da50
Bump Moq from 4.18.2 to 4.18.3
dependabot[bot] Dec 5, 2022
460d267
Merge pull request #1098 from microsoft/dependabot/nuget/Moq-4.18.3
baywet Dec 5, 2022
b530580
Merge pull request #1097 from microsoft/bugfix/validate-open-api-path…
baywet Dec 6, 2022
5e3d9d3
Merge pull request #1092 from microsoft/feature/sonarcloud
baywet Dec 6, 2022
043a592
Fixes bug where the schema copy constructor would run into a stack ov…
MaggieKimani1 Dec 6, 2022
8f87426
Add test to validate
MaggieKimani1 Dec 6, 2022
1dae8dc
Add test assertions
MaggieKimani1 Dec 6, 2022
563b046
Merge pull request #1099 from microsoft/mk/fix-schema-copy-constructo…
MaggieKimani1 Dec 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
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