Skip to content

Commit d8b9f3f

Browse files
authored
Merge pull request #666 from microsoft/feat/upgrade-oai
feat: bump openapi.net packages to the latest preview.
2 parents a578631 + 181d926 commit d8b9f3f

File tree

78 files changed

+439
-367
lines changed

Some content is hidden

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

78 files changed

+439
-367
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ public IEnumerable<ODataPath> AllPaths
135135
/// <summary>
136136
/// Gets all tags.
137137
/// </summary>
138-
public IList<OpenApiTag> Tags { get; private set; }
138+
public ISet<OpenApiTag> Tags { get; private set; }
139139

140140
/// <summary>
141141
/// Append tag.
142142
/// </summary>
143143
/// <param name="tagItem">The tag item.</param>
144144
internal void AppendTag(OpenApiTag tagItem)
145145
{
146-
Tags ??= [];
146+
Tags ??= new HashSet<OpenApiTag>();
147147

148148
if (FindTagByName(tagItem.Name) is not null)
149149
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static OpenApiDocument CreateDocument(this ODataContext context)
3838

3939
Servers = context.CreateServers(),
4040

41-
SecurityRequirements = null,
41+
Security = null,
4242

4343
ExternalDocs = null,
4444
};

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Net.Http;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Models;
1011
using Microsoft.OpenApi.Models.Interfaces;
@@ -58,9 +59,9 @@ public static void AddPathItemsToDocument(this ODataContext context, OpenApiDocu
5859
{
5960
OpenApiPathItem rootPath = new()
6061
{
61-
Operations = new Dictionary<OperationType, OpenApiOperation> {
62+
Operations = new Dictionary<HttpMethod, OpenApiOperation> {
6263
{
63-
OperationType.Get, new OpenApiOperation {
64+
HttpMethod.Get, new OpenApiOperation {
6465
OperationId = "graphService.GetGraphService",
6566
Responses = new OpenApiResponses()
6667
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal static class OpenApiTagGenerator
2222
/// </summary>
2323
/// <param name="context">The OData context.</param>
2424
/// <returns>The created collection of <see cref="OpenApiTag"/> object.</returns>
25-
public static IList<OpenApiTag> CreateTags(this ODataContext context)
25+
public static ISet<OpenApiTag> CreateTags(this ODataContext context)
2626
{
2727
Utils.CheckArgumentNull(context, nameof(context));
2828

@@ -38,7 +38,7 @@ public static IList<OpenApiTag> CreateTags(this ODataContext context)
3838
return context.Tags;
3939
}
4040

41-
IList<OpenApiTag> tags = new List<OpenApiTag>();
41+
var tags = new HashSet<OpenApiTag>();
4242
if (context.EntityContainer != null)
4343
{
4444
foreach (IEdmEntityContainerElement element in context.Model.EntityContainer.Elements)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
</PackageReference>
3131
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
32-
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
32+
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.14" />
3333
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
3434
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.61">
3535
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyBaseOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.OpenApi.OData.Common;
1010
using Microsoft.OpenApi.OData.Edm;
1111
using Microsoft.OpenApi.OData.Vocabulary.Core;
12+
using System.Collections.Generic;
1213

1314
namespace Microsoft.OpenApi.OData.Operation;
1415

@@ -35,7 +36,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
3536
protected override void SetTags(OpenApiOperation operation)
3637
{
3738
string tagName = EdmModelHelper.GenerateComplexPropertyPathTagName(Path, Context);
38-
39+
operation.Tags ??= new HashSet<OpenApiTagReference>();
3940
if (!string.IsNullOrEmpty(tagName))
4041
{
4142
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyGetOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Linq;
7+
using System.Net.Http;
78
using System.Text.Json.Nodes;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Any;
@@ -28,7 +29,7 @@ public ComplexPropertyGetOperationHandler(OpenApiDocument document):base(documen
2829

2930
}
3031
/// <inheritdoc />
31-
public override OperationType OperationType => OperationType.Get;
32+
public override HttpMethod OperationType => HttpMethod.Get;
3233

3334
private ReadRestrictionsType _readRestrictions;
3435

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyPatchOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OpenApi.Models;
78

89
namespace Microsoft.OpenApi.OData.Operation;
@@ -18,5 +19,5 @@ public ComplexPropertyPatchOperationHandler(OpenApiDocument document):base(docum
1819

1920
}
2021
/// <inheritdoc />
21-
public override OperationType OperationType => OperationType.Patch;
22+
public override HttpMethod OperationType => HttpMethod.Patch;
2223
}

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyPostOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Linq;
9+
using System.Net.Http;
910
using Microsoft.OData.Edm;
1011
using Microsoft.OpenApi.Models;
1112
using Microsoft.OpenApi.Models.References;
@@ -41,7 +42,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
4142
_insertRestrictions ??= complexPropertyInsertRestrictions;
4243
}
4344
/// <inheritdoc />
44-
public override OperationType OperationType => OperationType.Post;
45+
public override HttpMethod OperationType => HttpMethod.Post;
4546

4647
private InsertRestrictionsType _insertRestrictions;
4748

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyPutOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OpenApi.Models;
78

89
namespace Microsoft.OpenApi.OData.Operation;
@@ -18,5 +19,5 @@ public ComplexPropertyPutOperationHandler(OpenApiDocument document) : base(docum
1819

1920
}
2021
/// <inheritdoc />
21-
public override OperationType OperationType => OperationType.Put;
22+
public override HttpMethod OperationType => HttpMethod.Put;
2223
}

src/Microsoft.OpenApi.OData.Reader/Operation/ComplexPropertyUpdateOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Net.Http;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Models;
1011
using Microsoft.OpenApi.Models.Interfaces;
@@ -50,7 +51,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
5051
// OperationId
5152
if (Context.Settings.EnableOperationId)
5253
{
53-
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
54+
string prefix = OperationType == HttpMethod.Patch ? "Update" : "Set";
5455
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, Context, prefix);
5556
}
5657
}

src/Microsoft.OpenApi.OData.Reader/Operation/DollarCountGetOperationHandler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Collections.Generic;
88
using System.Linq;
9+
using System.Net.Http;
910
using Microsoft.OData.Edm;
1011
using Microsoft.OData.Edm.Vocabularies;
1112
using Microsoft.OpenApi.Any;
@@ -33,7 +34,7 @@ public DollarCountGetOperationHandler(OpenApiDocument document) : base(document)
3334

3435
}
3536
/// <inheritdoc/>
36-
public override OperationType OperationType => OperationType.Get;
37+
public override HttpMethod OperationType => HttpMethod.Get;
3738

3839
/// <summary>
3940
/// Gets/sets the segment before $count.
@@ -84,6 +85,8 @@ private void AddODataSegmentToAnnotables(ODataSegment oDataSegment, ODataSegment
8485
protected override void SetTags(OpenApiOperation operation)
8586
{
8687
string tagName = null;
88+
operation.Tags ??= new HashSet<OpenApiTagReference>();
89+
8790
if (SecondLastSegment is ODataNavigationSourceSegment sourceSegment)
8891
{
8992
tagName = TagNameFromNavigationSourceSegment(sourceSegment);

src/Microsoft.OpenApi.OData.Reader/Operation/EdmActionImportOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OData.Edm;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
@@ -25,7 +26,7 @@ public EdmActionImportOperationHandler(OpenApiDocument document):base(document)
2526

2627
}
2728
/// <inheritdoc/>
28-
public override OperationType OperationType => OperationType.Post;
29+
public override HttpMethod OperationType => HttpMethod.Post;
2930

3031
protected override void SetRequestBody(OpenApiOperation operation)
3132
{

src/Microsoft.OpenApi.OData.Reader/Operation/EdmActionOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OData.Edm;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
@@ -28,7 +29,7 @@ public EdmActionOperationHandler(OpenApiDocument document) : base(document)
2829

2930
}
3031
/// <inheritdoc/>
31-
public override OperationType OperationType => OperationType.Post;
32+
public override HttpMethod OperationType => HttpMethod.Post;
3233

3334
/// <inheritdoc/>
3435
protected override void SetBasicInfo(OpenApiOperation operation)

src/Microsoft.OpenApi.OData.Reader/Operation/EdmFunctionImportOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OData.Edm;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
@@ -25,7 +26,7 @@ public EdmFunctionImportOperationHandler(OpenApiDocument document) : base(docume
2526

2627
}
2728
/// <inheritdoc/>
28-
public override OperationType OperationType => OperationType.Get;
29+
public override HttpMethod OperationType => HttpMethod.Get;
2930

3031
/// <inheritdoc/>
3132
protected override void SetParameters(OpenApiOperation operation)

src/Microsoft.OpenApi.OData.Reader/Operation/EdmFunctionOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OData.Edm;
78
using Microsoft.OpenApi.Any;
89
using Microsoft.OpenApi.Models;
@@ -26,7 +27,7 @@ public EdmFunctionOperationHandler(OpenApiDocument document):base(document)
2627

2728
}
2829
/// <inheritdoc/>
29-
public override OperationType OperationType => OperationType.Get;
30+
public override HttpMethod OperationType => HttpMethod.Get;
3031

3132
/// <summary>
3233
/// Gets the Edm Function.

src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationImportOperationHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ protected override void SetTags(OpenApiOperation operation)
141141
var tag = CreateTag(EdmOperationImport);
142142
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
143143
Context.AppendTag(tag);
144+
145+
operation.Tags ??= new HashSet<OpenApiTagReference>();
144146
operation.Tags.Add(new OpenApiTagReference(tag.Name, _document));
145147

146148
base.SetTags(operation);

src/Microsoft.OpenApi.OData.Reader/Operation/EdmOperationOperationHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ protected override void SetTags(OpenApiOperation operation)
154154
Name = tagName,
155155
};
156156
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
157+
operation.Tags ??= new HashSet<OpenApiTagReference>();
157158
operation.Tags.Add(new OpenApiTagReference(tag.Name, _document));
158159

159160
Context.AppendTag(tag);

src/Microsoft.OpenApi.OData.Reader/Operation/EntityDeleteOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Linq;
7+
using System.Net.Http;
78
using Microsoft.OData.Edm;
89
using Microsoft.OpenApi.Models;
910
using Microsoft.OpenApi.OData.Common;
@@ -29,7 +30,7 @@ public EntityDeleteOperationHandler(OpenApiDocument document) : base(document)
2930

3031
}
3132
/// <inheritdoc/>
32-
public override OperationType OperationType => OperationType.Delete;
33+
public override HttpMethod OperationType => HttpMethod.Delete;
3334

3435
private DeleteRestrictionsType _deleteRestrictions;
3536

src/Microsoft.OpenApi.OData.Reader/Operation/EntityGetOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Microsoft.OpenApi.OData.Edm;
1414
using Microsoft.OpenApi.Models.References;
1515
using Microsoft.OpenApi.Models.Interfaces;
16+
using System.Net.Http;
1617

1718
namespace Microsoft.OpenApi.OData.Operation
1819
{
@@ -32,7 +33,7 @@ public EntityGetOperationHandler(OpenApiDocument document) : base(document)
3233

3334
}
3435
/// <inheritdoc/>
35-
public override OperationType OperationType => OperationType.Get;
36+
public override HttpMethod OperationType => HttpMethod.Get;
3637

3738
private ReadRestrictionsType _readRestrictions;
3839

src/Microsoft.OpenApi.OData.Reader/Operation/EntityPatchOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OpenApi.Models;
78

89
namespace Microsoft.OpenApi.OData.Operation
@@ -23,6 +24,6 @@ public EntityPatchOperationHandler(OpenApiDocument document) : base(document)
2324

2425
}
2526
/// <inheritdoc/>
26-
public override OperationType OperationType => OperationType.Patch;
27+
public override HttpMethod OperationType => HttpMethod.Patch;
2728
}
2829
}

src/Microsoft.OpenApi.OData.Reader/Operation/EntityPutOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6+
using System.Net.Http;
67
using Microsoft.OpenApi.Models;
78

89
namespace Microsoft.OpenApi.OData.Operation
@@ -23,6 +24,6 @@ public EntityPutOperationHandler(OpenApiDocument document) : base(document)
2324

2425
}
2526
/// <inheritdoc/>
26-
public override OperationType OperationType => OperationType.Put;
27+
public override HttpMethod OperationType => HttpMethod.Put;
2728
}
2829
}

src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetGetOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ------------------------------------------------------------
55

66
using System.Linq;
7+
using System.Net.Http;
78
using System.Text.Json.Nodes;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Any;
@@ -33,7 +34,7 @@ public EntitySetGetOperationHandler(OpenApiDocument document) : base(document)
3334

3435
}
3536
/// <inheritdoc/>
36-
public override OperationType OperationType => OperationType.Get;
37+
public override HttpMethod OperationType => HttpMethod.Get;
3738

3839
private ReadRestrictionsType _readRestrictions;
3940

src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.OpenApi.OData.Common;
1111
using Microsoft.OpenApi.OData.Edm;
1212
using Microsoft.OpenApi.OData.Vocabulary.Core;
13+
using System.Collections.Generic;
1314

1415
namespace Microsoft.OpenApi.OData.Operation
1516
{
@@ -46,7 +47,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
4647
protected override void SetTags(OpenApiOperation operation)
4748
{
4849
var tagName = EntitySet.Name + "." + EntitySet.EntityType.Name;
49-
50+
operation.Tags ??= new HashSet<OpenApiTagReference>();
5051
operation.Tags.Add(new OpenApiTagReference(tagName, _document));
5152

5253
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()

src/Microsoft.OpenApi.OData.Reader/Operation/EntitySetPostOperationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Net.Http;
89
using Microsoft.OData.Edm;
910
using Microsoft.OpenApi.Models;
1011
using Microsoft.OpenApi.Models.Interfaces;
@@ -33,7 +34,7 @@ public EntitySetPostOperationHandler(OpenApiDocument document) : base(document)
3334

3435
}
3536
/// <inheritdoc/>
36-
public override OperationType OperationType => OperationType.Post;
37+
public override HttpMethod OperationType => HttpMethod.Post;
3738

3839
private InsertRestrictionsType _insertRestrictions;
3940

0 commit comments

Comments
 (0)