Skip to content

Commit 0d8785e

Browse files
committed
Merge branch 'master' into is/explicit-operations-binding
2 parents 6fa4bb7 + d9474cf commit 0d8785e

File tree

58 files changed

+3349
-3494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3349
-3494
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Auto-merge dependabot updates
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
11+
jobs:
12+
13+
dependabot-merge:
14+
15+
runs-on: ubuntu-latest
16+
17+
if: ${{ github.actor == 'dependabot[bot]' }}
18+
19+
steps:
20+
- name: Dependabot metadata
21+
id: metadata
22+
uses: dependabot/fetch-metadata@v1.6.0
23+
with:
24+
github-token: "${{ secrets.GITHUB_TOKEN }}"
25+
26+
- name: Enable auto-merge for Dependabot PRs
27+
# Only if version bump is not a major version change
28+
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
4242
- name: Checkout repository
4343
id: checkout_repo
44-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
4545
with:
4646
token: ${{ secrets.GITHUB_TOKEN }}
4747
fetch-depth: 0

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v3
42+
uses: actions/checkout@v4
4343

4444
- name: Setup .NET
4545
uses: actions/setup-dotnet@v3.0.3

.github/workflows/sonarcloud.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ jobs:
2929
name: Build
3030
runs-on: windows-latest
3131
steps:
32-
- name: Set up JDK 11
32+
- name: Set up JDK 17
3333
uses: actions/setup-java@v3
3434
with:
3535
distribution: 'adopt'
36-
java-version: 11
36+
java-version: 17
3737
- name: Setup .NET 5 # At the moment the scanner requires dotnet 5 https://www.nuget.org/packages/dotnet-sonarscanner
3838
uses: actions/setup-dotnet@v3
3939
with:
@@ -42,7 +42,7 @@ jobs:
4242
uses: actions/setup-dotnet@v3
4343
with:
4444
dotnet-version: 7.0.x
45-
- uses: actions/checkout@v3
45+
- uses: actions/checkout@v4
4646
with:
4747
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
4848
- name: Cache SonarCloud packages

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"recommendations": [
3-
"formulahendry.dotnet-test-explorer",
43
"ms-dotnettools.csharp",
54
"editorconfig.editorconfig"
65
]

src/Microsoft.OpenApi.OData.Reader/Edm/ODataSegment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Microsoft.OData.Edm;
1010
using Microsoft.OpenApi.OData.Common;
1111
using Microsoft.OData.Edm.Vocabularies;
12-
using Microsoft.OpenApi.OData.OpenApiExtensions;
1312

1413
namespace Microsoft.OpenApi.OData.Edm
1514
{
@@ -109,7 +108,7 @@ public string GetPathItemName(OpenApiConvertSettings settings)
109108
return GetPathItemName(settings, new HashSet<string>());
110109
}
111110
/// <summary>
112-
/// Profides a suffix for the operation id based on the operation path.
111+
/// Provides a suffix for the operation id based on the operation path.
113112
/// </summary>
114113
/// <param name="path">Path to use to deduplicate.</param>
115114
/// <param name="settings">The settings.</param>
@@ -131,7 +130,8 @@ public string GetPathHash(OpenApiConvertSettings settings, ODataPath path = defa
131130
/// <summary>
132131
/// Provides any deprecation information for the segment.
133132
/// </summary>
134-
public OpenApiDeprecationExtension Deprecation { get; set; }
133+
[Obsolete("This property never returned any value or was used by the library.")]
134+
public Microsoft.OpenApi.OData.OpenApiExtensions.OpenApiDeprecationExtension Deprecation { get; set; }
135135
/// <summary>
136136
/// Returns the list of <see cref="IEdmVocabularyAnnotatable"/> this segment refers to.
137137
/// </summary>

src/Microsoft.OpenApi.OData.Reader/Edm/RecordExpressionExtensions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal static class RecordExpressionExtensions
2929
Utils.CheckArgumentNull(record, nameof(record));
3030
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
3131

32-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
32+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
3333
property.Value is IEdmIntegerConstantExpression value) ?
3434
value.Value :
3535
null;
@@ -46,7 +46,7 @@ public static string GetString(this IEdmRecordExpression record, string property
4646
Utils.CheckArgumentNull(record, nameof(record));
4747
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
4848

49-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
49+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
5050
property.Value is IEdmStringConstantExpression value) ?
5151
value.Value :
5252
null;
@@ -63,7 +63,7 @@ public static string GetString(this IEdmRecordExpression record, string property
6363
Utils.CheckArgumentNull(record, nameof(record));
6464
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
6565

66-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
66+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
6767
property.Value is IEdmBooleanConstantExpression value) ?
6868
value.Value :
6969
null;
@@ -80,7 +80,7 @@ public static string GetString(this IEdmRecordExpression record, string property
8080
Utils.CheckArgumentNull(record, nameof(record));
8181
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
8282

83-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
83+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
8484
property.Value is IEdmDateConstantExpression value) ?
8585
value.Value :
8686
null;
@@ -99,7 +99,7 @@ public static string GetString(this IEdmRecordExpression record, string property
9999
Utils.CheckArgumentNull(record, nameof(record));
100100
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
101101

102-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
102+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
103103
property.Value is IEdmEnumMemberExpression value &&
104104
value.EnumMembers != null &&
105105
value.EnumMembers.Any() &&
@@ -121,7 +121,7 @@ public static T GetRecord<T>(this IEdmRecordExpression record, string propertyNa
121121
Utils.CheckArgumentNull(record, nameof(record));
122122
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
123123

124-
if (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
124+
if (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
125125
property.Value is IEdmRecordExpression recordValue)
126126
{
127127
T a = new();
@@ -143,7 +143,7 @@ public static string GetPropertyPath(this IEdmRecordExpression record, string pr
143143
Utils.CheckArgumentNull(record, nameof(record));
144144
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
145145

146-
return (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
146+
return (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
147147
property.Value is IEdmPathExpression value) ?
148148
value.Path :
149149
null;
@@ -160,7 +160,7 @@ public static IList<string> GetCollectionPropertyPath(this IEdmRecordExpression
160160
Utils.CheckArgumentNull(record, nameof(record));
161161
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
162162

163-
if (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
163+
if (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
164164
property.Value is IEdmCollectionExpression value && value.Elements != null)
165165
{
166166
IList<string> properties =
@@ -189,7 +189,7 @@ public static IList<string> GetCollection(this IEdmRecordExpression record, stri
189189
Utils.CheckArgumentNull(record, nameof(record));
190190
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
191191

192-
if (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
192+
if (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
193193
property.Value is IEdmCollectionExpression collection && collection.Elements != null)
194194
{
195195
IList<string> items = collection.Elements
@@ -215,7 +215,7 @@ public static IList<T> GetCollection<T>(this IEdmRecordExpression record, string
215215
Utils.CheckArgumentNull(record, nameof(record));
216216
Utils.CheckArgumentNull(propertyName, nameof(propertyName));
217217

218-
if (record.Properties?.FirstOrDefault(e => e.Name == propertyName) is IEdmPropertyConstructor property &&
218+
if (record.Properties?.FirstOrDefault(e => propertyName.Equals(e.Name, StringComparison.Ordinal)) is IEdmPropertyConstructor property &&
219219
property.Value is IEdmCollectionExpression collection && collection.Elements != null)
220220
{
221221
IList<T> items = new List<T>();

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiErrorSchemaGenerator.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using Microsoft.OData.Edm;
9+
using Microsoft.OpenApi.Interfaces;
910
using Microsoft.OpenApi.Models;
1011
using Microsoft.OpenApi.OData.Common;
1112
using Microsoft.OpenApi.OData.Edm;
13+
using Microsoft.OpenApi.MicrosoftExtensions;
1214

1315
namespace Microsoft.OpenApi.OData.Generator
1416
{
@@ -133,7 +135,8 @@ public static OpenApiSchema CreateErrorMainSchema(string rootNamespaceName)
133135
"code", new OpenApiSchema { Type = "string", Nullable = false }
134136
},
135137
{
136-
"message", new OpenApiSchema { Type = "string", Nullable = false, }
138+
"message", new OpenApiSchema { Type = "string", Nullable = false, Extensions = new Dictionary<string, IOpenApiExtension>
139+
{ { OpenApiPrimaryErrorMessageExtension.Name, new OpenApiPrimaryErrorMessageExtension { IsPrimaryErrorMessage = true } } } }
137140
},
138141
{
139142
"target", new OpenApiSchema { Type = "string", Nullable = true }
@@ -155,7 +158,7 @@ public static OpenApiSchema CreateErrorMainSchema(string rootNamespaceName)
155158
}
156159
},
157160
{
158-
"innererror",
161+
"innerError",
159162
new OpenApiSchema
160163
{
161164
UnresolvedReference = true,

src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using Microsoft.OpenApi.Exceptions;
1616
using System.Linq;
1717
using Microsoft.OpenApi.Interfaces;
18-
using Microsoft.OpenApi.OData.OpenApiExtensions;
18+
using Microsoft.OpenApi.MicrosoftExtensions;
1919
using Microsoft.OpenApi.OData.Vocabulary.Core;
2020

2121
namespace Microsoft.OpenApi.OData.Generator
@@ -317,6 +317,17 @@ public static OpenApiSchema CreateEnumTypeSchema(this ODataContext context, IEdm
317317
// whose value is the value of the unqualified annotation Core.Description of the enumeration type.
318318
Description = context.Model.GetDescriptionAnnotation(enumType)
319319
};
320+
321+
// If the enum is flagged, add the extension info to the description
322+
if (context.Settings.AddEnumFlagsExtension && enumType.IsFlags)
323+
{
324+
var enumFlagsExtension = new OpenApiEnumFlagsExtension
325+
{
326+
IsFlags = true,
327+
};
328+
schema.Extensions.Add(OpenApiEnumFlagsExtension.Name, enumFlagsExtension);
329+
}
330+
320331
var extension = (context.Settings.OpenApiSpecVersion == OpenApiSpecVersion.OpenApi2_0 ||
321332
context.Settings.OpenApiSpecVersion == OpenApiSpecVersion.OpenApi3_0 ) &&
322333
context.Settings.AddEnumDescriptionExtension ?
@@ -333,7 +344,7 @@ public static OpenApiSchema CreateEnumTypeSchema(this ODataContext context, IEdm
333344
}
334345

335346
if(extension?.ValuesDescriptions.Any() ?? false)
336-
schema.Extensions.Add(extension.Name, extension);
347+
schema.Extensions.Add(OpenApiEnumValuesDescriptionExtension.Name, extension);
337348
schema.Title = enumType.Name;
338349
return schema;
339350
}

src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
<TargetFrameworks>netstandard2.0</TargetFrameworks>
1616
<PackageId>Microsoft.OpenApi.OData</PackageId>
1717
<SignAssembly>true</SignAssembly>
18-
<Version>1.5.0-preview1</Version>
18+
<Version>1.5.0-preview4</Version>
1919
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
2020
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
2121
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
2222
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET.OData</RepositoryUrl>
2323
<PackageReleaseNotes>
2424
- Resolves operation ids for $count and overloaded functions paths #382, #383
2525
- Updates README #13, #253, #40
26+
- Fixes casing in default propertyName for `innerError` in the `ErrorMainSchema`
27+
- Adds support for `x-ms-enum-flags` extension for flagged enums
2628
</PackageReleaseNotes>
2729
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
2830
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
@@ -42,8 +44,8 @@
4244
<PrivateAssets>all</PrivateAssets>
4345
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4446
</PackageReference>
45-
<PackageReference Include="Microsoft.OData.Edm" Version="7.16.0" />
46-
<PackageReference Include="Microsoft.OpenApi" Version="1.6.4" />
47+
<PackageReference Include="Microsoft.OData.Edm" Version="7.18.0" />
48+
<PackageReference Include="Microsoft.OpenApi" Version="1.6.9" />
4749
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
4850
<PrivateAssets>all</PrivateAssets>
4951
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)