Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
(#253) Sample for NSwag (#534)
Browse files Browse the repository at this point in the history
* (#253) First version of the NSwag support.

* (#253) Solution file

* (#253) NSwag support

* (#253) Sample for NSwag
  • Loading branch information
adrianhall authored Dec 17, 2022
1 parent 6cee766 commit 09d422a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion samples/Samples.NSwag/Models/AppdbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
/// <returns>A task that completes when the database is initialized</returns>
public async Task InitializeDatabaseAsync()
{
await this.Database.EnsureCreatedAsync().ConfigureAwait(false);
await Database.EnsureCreatedAsync();
}
}
}
6 changes: 2 additions & 4 deletions samples/Samples.NSwag/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Datasync;
using Microsoft.AspNetCore.Datasync.NSwag;
using Microsoft.EntityFrameworkCore;
using Samples.NSwag.Db;
using Samples.NSwag.Processors;

var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
Expand All @@ -10,9 +10,7 @@
builder.Services.AddDatasyncControllers();
builder.Services.AddOpenApiDocument(options =>
{
options.DocumentProcessors.Add(new DatasyncDocumentProcessor());
options.OperationProcessors.Add(new DatasyncOperationProcessor());
options.SchemaProcessors.Add(new DatasyncSchemaProcessor());
options.AddDatasyncProcessors();
});

var app = builder.Build();
Expand Down
37 changes: 19 additions & 18 deletions samples/Samples.NSwag/Samples.NSwag.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<UserSecretsId>B5ED561E-A4A8-461C-B2E8-82E0A348A303</UserSecretsId>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<UserSecretsId>B5ED561E-A4A8-461C-B2E8-82E0A348A303</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Datasync" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Datasync.EFCore" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NSwag.AspNetCore" Version="13.18.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Datasync" Version="5.0.18" />
<PackageReference Include="Microsoft.AspNetCore.Datasync.EFCore" Version="5.0.18" />
<PackageReference Include="Microsoft.AspNetCore.Datasync.NSwag" Version="5.0.18"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NSwag.AspNetCore" Version="13.18.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/Samples.NSwag/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=TodoItemsSample;Trusted_Connection=True;MultipleActiveResultSets=true"
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=NSwagSample;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
Expand Down

0 comments on commit 09d422a

Please sign in to comment.