added swagger api documentation
This commit is contained in:
parent
3234c68962
commit
f39ca4ad4c
|
|
@ -12,7 +12,7 @@
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "weatherforecast",
|
"launchUrl": "swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
"TestApplication": {
|
"TestApplication": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "weatherforecast",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|
|
||||||
14
Startup.cs
14
Startup.cs
|
|
@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
using TestApplication.Data;
|
using TestApplication.Data;
|
||||||
|
|
||||||
namespace TestApplication
|
namespace TestApplication
|
||||||
|
|
@ -25,6 +26,17 @@ namespace TestApplication
|
||||||
{
|
{
|
||||||
opt.UseMySql(Configuration.GetConnectionString("DefaultConnection"));
|
opt.UseMySql(Configuration.GetConnectionString("DefaultConnection"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddSwaggerGen(swagger =>
|
||||||
|
{
|
||||||
|
//This is to generate the Default UI of Swagger Documentation
|
||||||
|
swagger.SwaggerDoc("v1", new OpenApiInfo
|
||||||
|
{
|
||||||
|
Version= "v1",
|
||||||
|
Title = "ICDL Ireland Shop",
|
||||||
|
Description="ASP.NET Core 3.1 Web API Documentaion"
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
|
@ -33,6 +45,8 @@ namespace TestApplication
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12"/>
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.12"/>
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1"/>
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1"/>
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Loading…
Reference in New Issue