Skip to content

Commit c0d4918

Browse files
committed
add SwaggerUI to example project
1 parent a61d571 commit c0d4918

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />
1313
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlPostgreSQLVersion)" />
14+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="$(SwashbuckleVersion)" />
1415
</ItemGroup>
1516
</Project>

src/Examples/JsonApiDotNetCoreExample/Startup.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using JsonApiDotNetCore.Configuration;
33
using JsonApiDotNetCore.Diagnostics;
4+
using JsonApiDotNetCore.OpenApi;
45
using JsonApiDotNetCoreExample.Data;
56
using Microsoft.AspNetCore.Authentication;
67
using Microsoft.AspNetCore.Builder;
@@ -44,6 +45,10 @@ public void ConfigureServices(IServiceCollection services)
4445
#endif
4546
});
4647

48+
IMvcCoreBuilder mvcCoreBuilder = services.AddMvcCore();
49+
50+
services.AddOpenApi(mvcCoreBuilder);
51+
4752
using (CodeTimingSessionManager.Current.Measure("Configure JSON:API (startup)"))
4853
{
4954
services.AddJsonApi<AppDbContext>(options =>
@@ -57,7 +62,7 @@ public void ConfigureServices(IServiceCollection services)
5762
#if DEBUG
5863
options.IncludeExceptionStackTraceInErrors = true;
5964
#endif
60-
}, discovery => discovery.AddCurrentAssembly());
65+
}, discovery => discovery.AddCurrentAssembly(), mvcBuilder: mvcCoreBuilder);
6166
}
6267
}
6368
}
@@ -77,6 +82,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment environment,
7782

7883
app.UseRouting();
7984

85+
app.UseSwagger();
86+
app.UseSwaggerUI();
87+
8088
using (CodeTimingSessionManager.Current.Measure("Initialize JSON:API (startup)"))
8189
{
8290
app.UseJsonApi();

src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleVersion)" />
1212
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="$(SwashbuckleVersion)" />
1313
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="$(SwashbuckleVersion)" />
14-
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="$(SwashbuckleVersion)" />
1514
</ItemGroup>
1615
</Project>

0 commit comments

Comments
 (0)