Skip to content

Commit 38e6603

Browse files
committed
Upgrade Microsoft.OpenApi v2
1 parent 49ccd27 commit 38e6603

34 files changed

Lines changed: 555 additions & 550 deletions

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.10" />
2929
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.10" />
3030
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
31-
<PackageVersion Include="Microsoft.OpenApi" Version="1.6.23" />
31+
<PackageVersion Include="Microsoft.OpenApi" Version="2.3.7" />
3232
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.10" />
3333
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.10" />
3434
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="9.0.10" />
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
namespace Dibix.Sdk.Abstractions
1+
using System.Threading.Tasks;
2+
3+
namespace Dibix.Sdk.Abstractions
24
{
35
public interface ITask
46
{
5-
bool Execute();
7+
Task<bool> Execute();
68
}
79
}

src/Dibix.Sdk.Cli/Dibix.Sdk.Cli.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
4040
<_ToolItem Include="Dibix.exe" />
4141
<_ToolItem Include="Dibix.exe.config" />
42+
<_ToolItem Include="Microsoft.Bcl.AsyncInterfaces.dll" />
4243
<_ToolItem Include="Microsoft.Build.Framework.dll" />
4344
<_ToolItem Include="Microsoft.Build.Utilities.Core.dll" />
4445
<_ToolItem Include="Microsoft.CodeAnalysis.CSharp.dll" />
@@ -52,12 +53,16 @@
5253
<_ToolItem Include="Microsoft.SqlServer.TransactSql.ScriptDom.dll" />
5354
<_ToolItem Include="Newtonsoft.Json.dll" />
5455
<_ToolItem Include="Newtonsoft.Json.Schema.dll" />
56+
<_ToolItem Include="System.Buffers.dll" />
5557
<_ToolItem Include="System.Collections.Immutable.dll" />
5658
<_ToolItem Include="System.IO.Packaging.dll" />
5759
<_ToolItem Include="System.Memory.dll" />
5860
<_ToolItem Include="System.Numerics.Vectors.dll" />
5961
<_ToolItem Include="System.Reflection.Metadata.dll" />
6062
<_ToolItem Include="System.Runtime.CompilerServices.Unsafe.dll" />
63+
<_ToolItem Include="System.Text.Encodings.Web.dll" />
64+
<_ToolItem Include="System.Text.Json.dll" />
65+
<_ToolItem Include="System.Threading.Tasks.Extensions.dll" />
6166
<_ToolItem Include="System.ValueTuple.dll" />
6267
</ItemGroup>
6368

src/Dibix.Sdk.Cli/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using System;
2+
using System.Threading.Tasks;
23
using Dibix.Sdk.Abstractions;
34

45
namespace Dibix.Sdk.Cli
56
{
67
internal static class Program
78
{
8-
private static int Main(string[] args)
9+
private static async Task<int> Main(string[] args)
910
{
1011
#if DEBUG
1112
System.Diagnostics.Debugger.Launch();
@@ -23,7 +24,7 @@ private static int Main(string[] args)
2324
string runnerName = args[0];
2425

2526
ILogger logger = new Logger(Console.Out, distinctErrorLogging: true);
26-
if (!TaskRunner.Execute(runnerName, args, logger))
27+
if (!await TaskRunner.Execute(runnerName, args, logger).ConfigureAwait(false))
2728
return PrintHelp();
2829

2930
return 0;

src/Dibix.Sdk.Cli/TaskRunner.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Linq.Expressions;
55
using System.Reflection;
6+
using System.Threading.Tasks;
67
using Dibix.Sdk.Abstractions;
78

89
namespace Dibix.Sdk.Cli
@@ -19,15 +20,15 @@ internal static class TaskRunner
1920

2021
public static IEnumerable<string> RegisteredTaskRunnerNames => Tasks.Keys;
2122

22-
public static bool Execute(string runnerName, string[] args, ILogger logger)
23+
public static async Task<bool> Execute(string runnerName, string[] args, ILogger logger)
2324
{
2425
if (Tasks.TryGetValue(runnerName, out TaskRegistration registration))
2526
{
2627
InputConfiguration configuration = CollectInputConfiguration(registration, args);
2728
VisualStudioAwareLogger visualStudioAwareLogger = new VisualStudioAwareLogger(logger);
2829
visualStudioAwareLogger.BuildingInsideVisualStudio = configuration.GetSingleValue<bool>("BuildingInsideVisualStudio", throwOnInvalidKey: false);
2930
ITask task = registration.Factory(visualStudioAwareLogger, configuration);
30-
return task.Execute();
31+
return await task.Execute().ConfigureAwait(false);
3132
}
3233
return false;
3334
}

src/Dibix.Sdk.CodeGeneration/Configuration/CodeGenerationConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public sealed class CodeGenerationConfiguration
2424
public string OpenApiVersion { get; set; }
2525
public string BaseUrl { get; set; }
2626
public string OpenApiDescription { get; set; }
27-
public bool SupportOpenApiNullableReferenceTypes { get; set; }
2827
public ConfigurationTemplates ConfigurationTemplates { get; } = new ConfigurationTemplates();
2928
public ICollection<TaskItem> Source { get; } = new Collection<TaskItem>();
3029
public ICollection<TaskItem> Contracts { get; } = new Collection<TaskItem>();

src/Dibix.Sdk.CodeGeneration/Mapping/PrimitiveTypeMap.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Data;
4-
using Microsoft.OpenApi.Models;
4+
using Microsoft.OpenApi;
55
using Microsoft.SqlServer.TransactSql.ScriptDom;
66

77
namespace Dibix.Sdk.CodeGeneration
@@ -60,24 +60,24 @@ internal static class PrimitiveTypeMap
6060
};
6161
private static readonly IDictionary<PrimitiveType, Func<OpenApiSchema>> OpenApiTypeMap = new Dictionary<PrimitiveType, Func<OpenApiSchema>>
6262
{
63-
[PrimitiveType.Boolean] = () => new OpenApiSchema { Type = "boolean" }
64-
, [PrimitiveType.Byte] = () => new OpenApiSchema { Type = "integer", Format = "int32" }
65-
, [PrimitiveType.Int16] = () => new OpenApiSchema { Type = "integer", Format = "int32" }
66-
, [PrimitiveType.Int32] = () => new OpenApiSchema { Type = "integer", Format = "int32" }
67-
, [PrimitiveType.Int64] = () => new OpenApiSchema { Type = "integer", Format = "int64" }
68-
, [PrimitiveType.Float] = () => new OpenApiSchema { Type = "number", Format = "float" }
69-
, [PrimitiveType.Double] = () => new OpenApiSchema { Type = "number", Format = "double" }
70-
, [PrimitiveType.Decimal] = () => new OpenApiSchema { Type = "number", Format = "double" }
71-
, [PrimitiveType.Binary] = () => new OpenApiSchema { Type = "string", Format = "byte" }
72-
, [PrimitiveType.Stream] = () => new OpenApiSchema { Type = "string", Format = "binary" }
73-
, [PrimitiveType.Date] = () => new OpenApiSchema { Type = "string", Format = "date" }
74-
, [PrimitiveType.Time] = () => new OpenApiSchema { Type = "string", Format = "time" }
75-
, [PrimitiveType.DateTime] = () => new OpenApiSchema { Type = "string", Format = "date-time" }
76-
, [PrimitiveType.DateTimeOffset] = () => new OpenApiSchema { Type = "string", Format = "date-time" }
77-
, [PrimitiveType.String] = () => new OpenApiSchema { Type = "string" }
78-
, [PrimitiveType.Uri] = () => new OpenApiSchema { Type = "string", Format = "uri" }
79-
, [PrimitiveType.UUID] = () => new OpenApiSchema { Type = "string", Format = "uuid" }
80-
, [PrimitiveType.Xml] = () => new OpenApiSchema { Type = "string" }
63+
[PrimitiveType.Boolean] = () => new OpenApiSchema { Type = JsonSchemaType.Boolean }
64+
, [PrimitiveType.Byte] = () => new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32" }
65+
, [PrimitiveType.Int16] = () => new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32" }
66+
, [PrimitiveType.Int32] = () => new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int32" }
67+
, [PrimitiveType.Int64] = () => new OpenApiSchema { Type = JsonSchemaType.Integer, Format = "int64" }
68+
, [PrimitiveType.Float] = () => new OpenApiSchema { Type = JsonSchemaType.Number, Format = "float" }
69+
, [PrimitiveType.Double] = () => new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double" }
70+
, [PrimitiveType.Decimal] = () => new OpenApiSchema { Type = JsonSchemaType.Number, Format = "double" }
71+
, [PrimitiveType.Binary] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "byte" }
72+
, [PrimitiveType.Stream] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "binary" }
73+
, [PrimitiveType.Date] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "date" }
74+
, [PrimitiveType.Time] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "time" }
75+
, [PrimitiveType.DateTime] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "date-time" }
76+
, [PrimitiveType.DateTimeOffset] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "date-time" }
77+
, [PrimitiveType.String] = () => new OpenApiSchema { Type = JsonSchemaType.String }
78+
, [PrimitiveType.Uri] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "uri" }
79+
, [PrimitiveType.UUID] = () => new OpenApiSchema { Type = JsonSchemaType.String, Format = "uuid" }
80+
, [PrimitiveType.Xml] = () => new OpenApiSchema { Type = JsonSchemaType.String }
8181
};
8282

8383
public static bool TryGetPrimitiveType(SqlDataTypeOption sqlDataType, out PrimitiveType primitiveType) => ScriptDomTypeMap.TryGetValue(sqlDataType, out primitiveType);

0 commit comments

Comments
 (0)