Skip to content

Commit

Permalink
Add swagger support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferenc Hammerl committed Oct 20, 2020
1 parent 8c455f2 commit 726dabb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions ExpenseTracker.Api/ExpenseTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.0" />
</ItemGroup>


Expand Down
11 changes: 11 additions & 0 deletions ExpenseTracker.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ExpenseTrackerContext>(options => options.UseSqlite($"Data Source=ExpenseTracker.Api/expensetracker.db"));
}
services.AddSwaggerGen();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -44,6 +45,16 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
}

// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();

// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});

app.UseHttpsRedirection();

Expand Down

0 comments on commit 726dabb

Please sign in to comment.