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.
1111
1212 using CommunityToolkit.Datasync.Server.OpenApi;
1313
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:
1515
16+ builder.Services.AddEndpointsApiExplorer();
1617 builder.Services.AddOpenApi(options => options.AddDatasyncTransformers());
1718
18194 . 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
2728
2829## Known issues
2930
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 1010namespace Sample . Datasync . Server . Controllers ;
1111
1212[ Route ( "tables/[controller]" ) ]
13+ [ ApiExplorerSettings ( IgnoreApi = false ) ]
1314public class TodoItemController : TableController < TodoItem >
1415{
1516 public TodoItemController ( AppDbContext context )
Original file line number Diff line number Diff line change 1010namespace Sample . Datasync . Server . Controllers ;
1111
1212[ Route ( "tables/[controller]" ) ]
13+ [ ApiExplorerSettings ( IgnoreApi = false ) ]
1314public class TodoListController : TableController < TodoList >
1415{
1516 public TodoListController ( AppDbContext context ) : base ( new EntityTableRepository < TodoList > ( context ) )
Original file line number Diff line number Diff line change 66using CommunityToolkit . Datasync . Server . NSwag ;
77using CommunityToolkit . Datasync . Server . OpenApi ;
88using CommunityToolkit . Datasync . Server . Swashbuckle ;
9+ using Microsoft . AspNetCore . Mvc ;
910using Microsoft . EntityFrameworkCore ;
1011using Sample . Datasync . Server . Db ;
1112
3637
3738if ( openApiEnabled )
3839{
40+ // Explicit API Explorer configuration
41+ _ = builder . Services . AddEndpointsApiExplorer ( ) ;
3942 _ = builder . Services . AddOpenApi ( options => options . AddDatasyncTransformers ( ) ) ;
4043}
4144
6063 _ = app . UseSwagger ( ) . UseSwaggerUI ( ) ;
6164}
6265
66+ app . UseAuthorization ( ) ;
67+ app . MapControllers ( ) ;
68+
6369if ( openApiEnabled )
6470{
6571 _ = app . MapOpenApi ( pattern : "swagger/{documentName}/swagger.json" ) ;
6672 _ = app . UseSwaggerUI ( options => options . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "Sample.Datasync.Server v1" ) ) ;
6773}
6874
69- app . UseAuthorization ( ) ;
70- app . MapControllers ( ) ;
71-
7275app . Run ( ) ;
Original file line number Diff line number Diff line change 77 </PropertyGroup >
88
99 <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" >
1813 <PrivateAssets >all</PrivateAssets >
1914 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
2015 </PackageReference >
2116 </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 >
2225</Project >
You can’t perform that action at this time.
0 commit comments