Skip to content

feat: bump openapi.net packages to the latest preview. #666

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

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi.OData.Reader/Edm/ODataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ public IEnumerable<ODataPath> AllPaths
/// <summary>
/// Gets all tags.
/// </summary>
public IList<OpenApiTag> Tags { get; private set; }
public ISet<OpenApiTag> Tags { get; private set; }

/// <summary>
/// Append tag.
/// </summary>
/// <param name="tagItem">The tag item.</param>
internal void AppendTag(OpenApiTag tagItem)
{
Tags ??= [];
Tags ??= new HashSet<OpenApiTag>();

if (FindTagByName(tagItem.Name) is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Utils.CheckArgumentNull(context, nameof(context));

// An OAS document consists of a single OpenAPI Object represented as OpenApiDocument object.
// {

Check warning on line 27 in src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiDocumentGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
// "openapi":"3.0.0",
// "info": …,
// "servers": …,
Expand All @@ -38,7 +38,7 @@

Servers = context.CreateServers(),

SecurityRequirements = null,
Security = null,

ExternalDocs = null,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -58,9 +59,9 @@ public static void AddPathItemsToDocument(this ODataContext context, OpenApiDocu
{
OpenApiPathItem rootPath = new()
{
Operations = new Dictionary<OperationType, OpenApiOperation> {
Operations = new Dictionary<HttpMethod, OpenApiOperation> {
{
OperationType.Get, new OpenApiOperation {
HttpMethod.Get, new OpenApiOperation {
OperationId = "graphService.GetGraphService",
Responses = new OpenApiResponses()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class OpenApiTagGenerator
/// </summary>
/// <param name="context">The OData context.</param>
/// <returns>The created collection of <see cref="OpenApiTag"/> object.</returns>
public static IList<OpenApiTag> CreateTags(this ODataContext context)
public static ISet<OpenApiTag> CreateTags(this ODataContext context)
{
Utils.CheckArgumentNull(context, nameof(context));

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

IList<OpenApiTag> tags = new List<OpenApiTag>();
var tags = new HashSet<OpenApiTag>();
if (context.EntityContainer != null)
{
foreach (IEdmEntityContainerElement element in context.Model.EntityContainer.Elements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview9" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.14" />
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.61">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.OpenApi.OData.Common;
using Microsoft.OpenApi.OData.Edm;
using Microsoft.OpenApi.OData.Vocabulary.Core;
using System.Collections.Generic;

namespace Microsoft.OpenApi.OData.Operation;

Expand All @@ -35,7 +36,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
protected override void SetTags(OpenApiOperation operation)
{
string tagName = EdmModelHelper.GenerateComplexPropertyPathTagName(Path, Context);

operation.Tags ??= new HashSet<OpenApiTagReference>();
if (!string.IsNullOrEmpty(tagName))
{
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------------------------------------------------------------

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

}
/// <inheritdoc />
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

private ReadRestrictionsType _readRestrictions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OpenApi.Models;

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

}
/// <inheritdoc />
public override OperationType OperationType => OperationType.Patch;
public override HttpMethod OperationType => HttpMethod.Patch;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
_insertRestrictions ??= complexPropertyInsertRestrictions;
}
/// <inheritdoc />
public override OperationType OperationType => OperationType.Post;
public override HttpMethod OperationType => HttpMethod.Post;

private InsertRestrictionsType _insertRestrictions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OpenApi.Models;

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

}
/// <inheritdoc />
public override OperationType OperationType => OperationType.Put;
public override HttpMethod OperationType => HttpMethod.Put;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -50,7 +51,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
// OperationId
if (Context.Settings.EnableOperationId)
{
string prefix = OperationType == OperationType.Patch ? "Update" : "Set";
string prefix = OperationType == HttpMethod.Patch ? "Update" : "Set";
operation.OperationId = EdmModelHelper.GenerateComplexPropertyPathOperationId(Path, Context, prefix);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
using Microsoft.OpenApi.Any;
Expand Down Expand Up @@ -33,7 +34,7 @@ public DollarCountGetOperationHandler(OpenApiDocument document) : base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

/// <summary>
/// Gets/sets the segment before $count.
Expand Down Expand Up @@ -84,6 +85,8 @@ private void AddODataSegmentToAnnotables(ODataSegment oDataSegment, ODataSegment
protected override void SetTags(OpenApiOperation operation)
{
string tagName = null;
operation.Tags ??= new HashSet<OpenApiTagReference>();

if (SecondLastSegment is ODataNavigationSourceSegment sourceSegment)
{
tagName = TagNameFromNavigationSourceSegment(sourceSegment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
Expand All @@ -25,7 +26,7 @@ public EdmActionImportOperationHandler(OpenApiDocument document):base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Post;
public override HttpMethod OperationType => HttpMethod.Post;

protected override void SetRequestBody(OpenApiOperation operation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
Expand All @@ -28,7 +29,7 @@ public EdmActionOperationHandler(OpenApiDocument document) : base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Post;
public override HttpMethod OperationType => HttpMethod.Post;

/// <inheritdoc/>
protected override void SetBasicInfo(OpenApiOperation operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

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

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

/// <inheritdoc/>
protected override void SetParameters(OpenApiOperation operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
Expand All @@ -26,7 +27,7 @@ public EdmFunctionOperationHandler(OpenApiDocument document):base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

/// <summary>
/// Gets the Edm Function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ protected override void SetTags(OpenApiOperation operation)
var tag = CreateTag(EdmOperationImport);
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
Context.AppendTag(tag);

operation.Tags ??= new HashSet<OpenApiTagReference>();
operation.Tags.Add(new OpenApiTagReference(tag.Name, _document));

base.SetTags(operation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ protected override void SetTags(OpenApiOperation operation)
Name = tagName,
};
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
operation.Tags ??= new HashSet<OpenApiTagReference>();
operation.Tags.Add(new OpenApiTagReference(tag.Name, _document));

Context.AppendTag(tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------------------------------------------------------------

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

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Delete;
public override HttpMethod OperationType => HttpMethod.Delete;

private DeleteRestrictionsType _deleteRestrictions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.OpenApi.OData.Edm;
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.Models.Interfaces;
using System.Net.Http;

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

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

private ReadRestrictionsType _readRestrictions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OpenApi.Models;

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

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Patch;
public override HttpMethod OperationType => HttpMethod.Patch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Net.Http;
using Microsoft.OpenApi.Models;

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

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Put;
public override HttpMethod OperationType => HttpMethod.Put;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// ------------------------------------------------------------

using System.Linq;
using System.Net.Http;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
Expand Down Expand Up @@ -33,7 +34,7 @@ public EntitySetGetOperationHandler(OpenApiDocument document) : base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Get;
public override HttpMethod OperationType => HttpMethod.Get;

private ReadRestrictionsType _readRestrictions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.OpenApi.OData.Common;
using Microsoft.OpenApi.OData.Edm;
using Microsoft.OpenApi.OData.Vocabulary.Core;
using System.Collections.Generic;

namespace Microsoft.OpenApi.OData.Operation
{
Expand Down Expand Up @@ -46,7 +47,7 @@ protected override void Initialize(ODataContext context, ODataPath path)
protected override void SetTags(OpenApiOperation operation)
{
var tagName = EntitySet.Name + "." + EntitySet.EntityType.Name;

operation.Tags ??= new HashSet<OpenApiTagReference>();
operation.Tags.Add(new OpenApiTagReference(tagName, _document));

Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -33,7 +34,7 @@ public EntitySetPostOperationHandler(OpenApiDocument document) : base(document)

}
/// <inheritdoc/>
public override OperationType OperationType => OperationType.Post;
public override HttpMethod OperationType => HttpMethod.Post;

private InsertRestrictionsType _insertRestrictions;

Expand Down
Loading
Loading