Skip to content

Commit 55a1712

Browse files
authored
(#275) Added OpenApi support. (#313)
1 parent 7f68b16 commit 55a1712

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

samples/datasync-server/src/Sample.Datasync.Server/Program.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using CommunityToolkit.Datasync.Server;
66
using CommunityToolkit.Datasync.Server.NSwag;
7+
using CommunityToolkit.Datasync.Server.OpenApi;
78
using CommunityToolkit.Datasync.Server.Swashbuckle;
89
using Microsoft.EntityFrameworkCore;
910
using Sample.Datasync.Server.Db;
@@ -33,10 +34,10 @@
3334
_ = builder.Services.AddSwaggerGen(options => options.AddDatasyncControllers());
3435
}
3536

36-
//if (openApiEnabled)
37-
//{
38-
// _ = builder.Services.AddOpenApi(options => options.AddDatasyncTransformers());
39-
//}
37+
if (openApiEnabled)
38+
{
39+
_ = builder.Services.AddOpenApi(options => options.AddDatasyncTransformers());
40+
}
4041

4142
WebApplication app = builder.Build();
4243

@@ -59,12 +60,13 @@
5960
_ = app.UseSwagger().UseSwaggerUI();
6061
}
6162

63+
if (openApiEnabled)
64+
{
65+
_ = app.MapOpenApi(pattern: "swagger/{documentName}/swagger.json");
66+
_ = app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample.Datasync.Server v1"));
67+
}
68+
6269
app.UseAuthorization();
6370
app.MapControllers();
6471

65-
//if (openApiEnabled)
66-
//{
67-
// _ = app.MapOpenApi(pattern: "swagger/{documentName}/swagger.json");
68-
//}
69-
7072
app.Run();

samples/datasync-server/src/Sample.Datasync.Server/Sample.Datasync.Server.csproj

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
33
<TargetFramework>net9.0</TargetFramework>
44
<Nullable>enable</Nullable>
@@ -7,13 +7,14 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.0" />
11-
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="9.0.0" />
12-
<PackageReference Include="CommunityToolkit.Datasync.Server.NSwag" Version="9.0.0" />
13-
<PackageReference Include="CommunityToolkit.Datasync.Server.Swashbuckle" Version="9.0.0" />
14-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
10+
<PackageReference Include="CommunityToolkit.Datasync.Server" Version="9.0.1" />
11+
<PackageReference Include="CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version="9.0.1" />
12+
<PackageReference Include="CommunityToolkit.Datasync.Server.NSwag" Version="9.0.1" />
13+
<PackageReference Include="CommunityToolkit.Datasync.Server.OpenApi" Version="9.0.1" />
14+
<PackageReference Include="CommunityToolkit.Datasync.Server.Swashbuckle" Version="9.0.1" />
15+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.2" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.2" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
1718
<PrivateAssets>all</PrivateAssets>
1819
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1920
</PackageReference>

0 commit comments

Comments
 (0)