Skip to content
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/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -159,7 +159,7 @@ internal static void AddCustomAttributesToExtensions(this IDictionary<string, IO
{
foreach (var item in attributesValueMap)
{
extensions.TryAdd(item.Key, new OpenApiAny(item.Value));
extensions.TryAdd(item.Key, new JsonNodeExtension(item.Value));
}
}
}
Expand Down
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 @@ -8,7 +8,7 @@
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -172,7 +172,7 @@ internal void AppendTag(OpenApiTag tagItem)
/// <param name="extensionName">The extension name.</param>
/// <param name="extensionValue">The extension value to set.</param>
/// <param name="initialValueFactory">The tag default value factory.</param>
internal void AddExtensionToTag(string tagName, string extensionName, OpenApiAny extensionValue, Func<OpenApiTag> initialValueFactory)
internal void AddExtensionToTag(string tagName, string extensionName, JsonNodeExtension extensionValue, Func<OpenApiTag> initialValueFactory)
{
Utils.CheckArgumentNullOrEmpty(tagName, nameof(tagName));
Utils.CheckArgumentNullOrEmpty(extensionName, nameof(extensionName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Validation;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -48,7 +48,7 @@ public static OpenApiDocument ConvertToOpenApi(this IEdmModel model, OpenApiConv
document.Extensions ??= new Dictionary<string, IOpenApiExtension>();
foreach (var error in errors)
{
document.Extensions.Add(Constants.xMsEdmModelError + index++, new OpenApiAny(error.ToString()));
document.Extensions.Add(Constants.xMsEdmModelError + index++, new JsonNodeExtension(error.ToString()));
}

return document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Reflection;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -48,7 +48,7 @@

// The value of title is the value of the unqualified annotation Core.Description
// of the main schema or the entity container of the OData service.
// TODO: https://github.com/Microsoft/OpenAPI.NET.OData/issues/2

Check warning on line 51 in src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiInfoGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

// or the entity container
if (context.Model.EntityContainer != null)
Expand All @@ -74,7 +74,7 @@

// The value of version is the value of the annotation Core.SchemaVersion of the main schema.
// If no Core.SchemaVersion is present, a default version has to be provided as this is a required OpenAPI field.
// TODO: https://github.com/Microsoft/OpenAPI.NET.OData/issues/2

Check warning on line 77 in src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiInfoGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

return context.Settings.SemVerVersion;
}
Expand All @@ -84,7 +84,7 @@
Debug.Assert(context != null);

// The value of description is the value of the annotation Core.LongDescription of the main schema.
// TODO: https://github.com/Microsoft/OpenAPI.NET.OData/issues/2

Check warning on line 87 in src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiInfoGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

// or the entity container
if (context.EntityContainer != null)
Expand All @@ -110,7 +110,7 @@
{
{
"x-ms-generated-by",
new OpenApiAny(new JsonObject
new JsonNodeExtension(new JsonObject
{
{ "toolName", "Microsoft.OpenApi.OData" },
{ "toolVersion", Assembly.GetExecutingAssembly().GetName().Version?.ToString() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
using System.Diagnostics;
using System;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Extensions;

namespace Microsoft.OpenApi.OData.Generator
{
Expand Down Expand Up @@ -195,7 +195,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
};

parameter.Extensions ??= new Dictionary<string, IOpenApiExtension>();
parameter.Extensions.Add(Constants.xMsKeyType, new OpenApiAny(entityType.Name));
parameter.Extensions.Add(Constants.xMsKeyType, new JsonNodeExtension(entityType.Name));
parameters.Add(parameter);
}
else
Expand All @@ -221,7 +221,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
}

parameter.Extensions ??= new Dictionary<string, IOpenApiExtension>();
parameter.Extensions.Add(Constants.xMsKeyType, new OpenApiAny(entityType.Name));
parameter.Extensions.Add(Constants.xMsKeyType, new JsonNodeExtension(entityType.Name));
parameters.Add(parameter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Microsoft.OpenApi.MicrosoftExtensions;
using Microsoft.OpenApi.OData.Vocabulary.Core;
using System.Text.Json.Nodes;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models.References;
using System.Globalization;
Expand Down Expand Up @@ -452,7 +451,7 @@
// we always want a new copy because it's a reference
openApiSchema.Extensions = propertySchema.Extensions is null ? [] : new Dictionary<string, IOpenApiExtension>(propertySchema.Extensions);
openApiSchema.Extensions.AddCustomAttributesToExtensions(context, property);
openApiSchema.Extensions.Add(Constants.xMsNavigationProperty, new OpenApiAny(true));
openApiSchema.Extensions.Add(Constants.xMsNavigationProperty, new JsonNodeExtension(true));
}
properties.Add(property.Name, propertySchema);
}
Expand Down Expand Up @@ -514,7 +513,7 @@
{
extension = new Dictionary<string, IOpenApiExtension>
{
{ Constants.xMsDiscriminatorValue, new OpenApiAny("#" + structuredType.FullTypeName()) }
{ Constants.xMsDiscriminatorValue, new JsonNodeExtension("#" + structuredType.FullTypeName()) }
};
}

Expand Down Expand Up @@ -753,7 +752,7 @@
// The type 'System.Double' is not supported in Open API document.
case EdmPrimitiveTypeKind.Double:
/*
{

Check warning on line 755 in src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiSchemaGenerator.cs

View workflow job for this annotation

GitHub Actions / Build

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
double result;
if (Double.TryParse(property.DefaultValueString, out result))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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-preview.17" />
<PackageReference Include="Microsoft.OpenApi" Version="2.0.0-preview.18" />
<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 @@ -3,7 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -41,7 +41,7 @@ protected override void SetTags(OpenApiOperation operation)
operation.Tags ??= new HashSet<OpenApiTagReference>();
if (!string.IsNullOrEmpty(tagName))
{
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new JsonNodeExtension("page"), () => new OpenApiTag()
{
Name = tagName
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Net.Http;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -165,7 +165,7 @@ ComplexPropertySegment is not null &&
{ "operationName", Context.Settings.PageableOperationName}
};
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsPageable, new OpenApiAny(extension));
operation.Extensions.Add(Constants.xMsPageable, new JsonNodeExtension(extension));

base.SetExtensions(operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -113,7 +113,7 @@ protected override void SetTags(OpenApiOperation operation)

if (tagName != null && Context is not null)
{
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Context.AddExtensionToTag(tagName, Constants.xMsTocType, new JsonNodeExtension("page"), () => new OpenApiTag()
{
Name = tagName
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -44,7 +44,7 @@ protected override void SetRequestBody(OpenApiOperation operation)
protected override void SetExtensions(OpenApiOperation operation)
{
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsDosOperationType, new OpenApiAny("actionImport"));
operation.Extensions.Add(Constants.xMsDosOperationType, new JsonNodeExtension("actionImport"));

base.SetExtensions(operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -76,7 +76,7 @@ protected override void SetRequestBody(OpenApiOperation operation)
protected override void SetExtensions(OpenApiOperation operation)
{
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsDosOperationType, new OpenApiAny("action"));
operation.Extensions.Add(Constants.xMsDosOperationType, new JsonNodeExtension("action"));
base.SetExtensions(operation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -65,7 +65,7 @@ protected override void SetParameters(OpenApiOperation operation)
protected override void SetExtensions(OpenApiOperation operation)
{
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsDosOperationType, new OpenApiAny("functionImport"));
operation.Extensions.Add(Constants.xMsDosOperationType, new JsonNodeExtension("functionImport"));
base.SetExtensions(operation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -61,7 +61,7 @@ protected override void SetBasicInfo(OpenApiOperation operation)
protected override void SetExtensions(OpenApiOperation operation)
{
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsDosOperationType, new OpenApiAny("function"));
operation.Extensions.Add(Constants.xMsDosOperationType, new JsonNodeExtension("function"));
base.SetExtensions(operation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -150,7 +150,7 @@ protected override void SetTags(OpenApiOperation operation)
{
var tag = CreateTag(EdmOperationImport);
tag.Extensions ??= new Dictionary<string, IOpenApiExtension>();
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
tag.Extensions.Add(Constants.xMsTocType, new JsonNodeExtension("container"));
Context?.AppendTag(tag);

operation.Tags ??= new HashSet<OpenApiTagReference>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Linq;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -163,7 +163,7 @@ protected override void SetTags(OpenApiOperation operation)
Name = tagName,
};
tag.Extensions ??= new Dictionary<string, IOpenApiExtension>();
tag.Extensions.Add(Constants.xMsTocType, new OpenApiAny("container"));
tag.Extensions.Add(Constants.xMsTocType, new JsonNodeExtension("container"));
operation.Tags ??= new HashSet<OpenApiTagReference>();
operation.Tags.Add(new OpenApiTagReference(tag.Name, _document));

Expand Down Expand Up @@ -360,7 +360,7 @@ protected override void SetExtensions(OpenApiOperation operation)
};

operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsPageable, new OpenApiAny(extension));
operation.Extensions.Add(Constants.xMsPageable, new JsonNodeExtension(extension));
}
base.SetExtensions(operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Net.Http;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -81,7 +81,7 @@ protected override void SetExtensions(OpenApiOperation operation)
{ "operationName", Context.Settings.PageableOperationName}
};
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsPageable, new OpenApiAny(extension));
operation.Extensions.Add(Constants.xMsPageable, new JsonNodeExtension(extension));

base.SetExtensions(operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ------------------------------------------------------------

using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -50,7 +50,7 @@ protected override void SetTags(OpenApiOperation operation)
operation.Tags ??= new HashSet<OpenApiTagReference>();
operation.Tags.Add(new OpenApiTagReference(tagName, _document));

Context?.AddExtensionToTag(tagName, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Context?.AddExtensionToTag(tagName, Constants.xMsTocType, new JsonNodeExtension("page"), () => new OpenApiTag()
{
Name = tagName
});
Expand All @@ -62,7 +62,7 @@ protected override void SetTags(OpenApiOperation operation)
protected override void SetExtensions(OpenApiOperation operation)
{
operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsDosOperationType, new OpenApiAny("operation"));
operation.Extensions.Add(Constants.xMsDosOperationType, new JsonNodeExtension("operation"));

base.SetExtensions(operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// ------------------------------------------------------------

using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
using Microsoft.OpenApi.OData.Common;
Expand Down Expand Up @@ -94,7 +94,7 @@ protected override void SetTags(OpenApiOperation operation)
: NavigationSourceSegment?.Identifier + "." + NavigationSourceSegment?.EntityType.Name;


Context?.AddExtensionToTag(tagIdentifier, Constants.xMsTocType, new OpenApiAny("page"), () => new OpenApiTag()
Context?.AddExtensionToTag(tagIdentifier, Constants.xMsTocType, new JsonNodeExtension("page"), () => new OpenApiTag()
{
Name = tagIdentifier
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Net.Http;
using System.Text.Json.Nodes;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
Expand Down Expand Up @@ -83,7 +83,7 @@ protected override void SetExtensions(OpenApiOperation operation)
};

operation.Extensions ??= new Dictionary<string, IOpenApiExtension>();
operation.Extensions.Add(Constants.xMsPageable, new OpenApiAny(extension));
operation.Extensions.Add(Constants.xMsPageable, new JsonNodeExtension(extension));
}

base.SetExtensions(operation);
Expand Down
Loading
Loading