File tree Expand file tree Collapse file tree 5 files changed +22
-13
lines changed
docs/in-depth/server/openapi
samples/datasync-server/src/Sample.Datasync.Server Expand file tree Collapse file tree 5 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,9 @@ Follow [the basic instructions for OpenApi integration](https://learn.microsoft.
11
11
12
12
using CommunityToolkit.Datasync.Server.OpenApi;
13
13
14
- 3 . Add a service to generate an OpenAPI definition to your ` Program.cs ` file:
14
+ 3 . Add services to generate an OpenAPI definition to your ` Program.cs ` file:
15
15
16
+ builder.Services.AddEndpointsApiExplorer();
16
17
builder.Services.AddOpenApi(options => options.AddDatasyncTransformers());
17
18
18
19
4 . Enable the middleware for serving the generated JSON document and the Swagger UI, also in ` Program.cs ` :
@@ -27,4 +28,4 @@ Browsing to the `/openapi/v1.json` endpoint of the web service allows you to dow
27
28
28
29
## Known issues
29
30
30
- The .NET 9.x OpenApi support currently does not support dynamic schema generation. This means that the schema generated within the OpenApi document will be incomplete.
31
+ The .NET 9.x OpenApi support currently does not support dynamic schema generation. This means that the schema generated within the OpenApi document will be incomplete.
Original file line number Diff line number Diff line change 10
10
namespace Sample . Datasync . Server . Controllers ;
11
11
12
12
[ Route ( "tables/[controller]" ) ]
13
+ [ ApiExplorerSettings ( IgnoreApi = false ) ]
13
14
public class TodoItemController : TableController < TodoItem >
14
15
{
15
16
public TodoItemController ( AppDbContext context )
Original file line number Diff line number Diff line change 10
10
namespace Sample . Datasync . Server . Controllers ;
11
11
12
12
[ Route ( "tables/[controller]" ) ]
13
+ [ ApiExplorerSettings ( IgnoreApi = false ) ]
13
14
public class TodoListController : TableController < TodoList >
14
15
{
15
16
public TodoListController ( AppDbContext context ) : base ( new EntityTableRepository < TodoList > ( context ) )
Original file line number Diff line number Diff line change 6
6
using CommunityToolkit . Datasync . Server . NSwag ;
7
7
using CommunityToolkit . Datasync . Server . OpenApi ;
8
8
using CommunityToolkit . Datasync . Server . Swashbuckle ;
9
+ using Microsoft . AspNetCore . Mvc ;
9
10
using Microsoft . EntityFrameworkCore ;
10
11
using Sample . Datasync . Server . Db ;
11
12
36
37
37
38
if ( openApiEnabled )
38
39
{
40
+ // Explicit API Explorer configuration
41
+ _ = builder . Services . AddEndpointsApiExplorer ( ) ;
39
42
_ = builder . Services . AddOpenApi ( options => options . AddDatasyncTransformers ( ) ) ;
40
43
}
41
44
60
63
_ = app . UseSwagger ( ) . UseSwaggerUI ( ) ;
61
64
}
62
65
66
+ app . UseAuthorization ( ) ;
67
+ app . MapControllers ( ) ;
68
+
63
69
if ( openApiEnabled )
64
70
{
65
71
_ = app . MapOpenApi ( pattern : "swagger/{documentName}/swagger.json" ) ;
66
72
_ = app . UseSwaggerUI ( options => options . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "Sample.Datasync.Server v1" ) ) ;
67
73
}
68
74
69
- app . UseAuthorization ( ) ;
70
- app . MapControllers ( ) ;
71
-
72
75
app . Run ( ) ;
Original file line number Diff line number Diff line change 7
7
</PropertyGroup >
8
8
9
9
<ItemGroup >
10
- <PackageReference Include =" CommunityToolkit.Datasync.Server" Version =" 9.0.2" />
11
- <PackageReference Include =" CommunityToolkit.Datasync.Server.EntityFrameworkCore" Version =" 9.0.2" />
12
- <PackageReference Include =" CommunityToolkit.Datasync.Server.NSwag" Version =" 9.0.2" />
13
- <PackageReference Include =" CommunityToolkit.Datasync.Server.OpenApi" Version =" 9.0.2" />
14
- <PackageReference Include =" CommunityToolkit.Datasync.Server.Swashbuckle" Version =" 9.0.2" />
15
- <PackageReference Include =" Microsoft.AspNetCore.OpenApi" Version =" 9.0.5" />
16
- <PackageReference Include =" Microsoft.EntityFrameworkCore.SqlServer" Version =" 9.0.5" />
17
- <PackageReference Include =" Microsoft.EntityFrameworkCore.Tools" Version =" 9.0.5" >
10
+ <PackageReference Include =" Microsoft.AspNetCore.OpenApi" Version =" 9.0.7" />
11
+ <PackageReference Include =" Microsoft.EntityFrameworkCore.SqlServer" Version =" 9.0.7" />
12
+ <PackageReference Include =" Microsoft.EntityFrameworkCore.Tools" Version =" 9.0.7" >
18
13
<PrivateAssets >all</PrivateAssets >
19
14
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
20
15
</PackageReference >
21
16
</ItemGroup >
17
+
18
+ <ItemGroup >
19
+ <ProjectReference Include =" ..\..\..\..\src\CommunityToolkit.Datasync.Server.EntityFrameworkCore\CommunityToolkit.Datasync.Server.EntityFrameworkCore.csproj" />
20
+ <ProjectReference Include =" ..\..\..\..\src\CommunityToolkit.Datasync.Server.NSwag\CommunityToolkit.Datasync.Server.NSwag.csproj" />
21
+ <ProjectReference Include =" ..\..\..\..\src\CommunityToolkit.Datasync.Server.OpenApi\CommunityToolkit.Datasync.Server.OpenApi.csproj" />
22
+ <ProjectReference Include =" ..\..\..\..\src\CommunityToolkit.Datasync.Server.Swashbuckle\CommunityToolkit.Datasync.Server.Swashbuckle.csproj" />
23
+ <ProjectReference Include =" ..\..\..\..\src\CommunityToolkit.Datasync.Server\CommunityToolkit.Datasync.Server.csproj" />
24
+ </ItemGroup >
22
25
</Project >
You can’t perform that action at this time.
0 commit comments