forked from adam/discord-bot-shtik
integrate swagger
This commit is contained in:
parent
2f7bc2c0ea
commit
c6ea3ef790
@ -13,6 +13,7 @@ builder.Services.Configure<RazorViewEngineOptions>(o => {
|
|||||||
o.ViewLocationFormats.Add("/WebInterface/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
|
o.ViewLocationFormats.Add("/WebInterface/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
|
||||||
o.ViewLocationFormats.Add("/WebInterface/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
|
o.ViewLocationFormats.Add("/WebInterface/Views/Shared/{0}" + RazorViewEngine.ViewExtension);
|
||||||
});
|
});
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
@ -29,5 +30,11 @@ app.MapControllerRoute(
|
|||||||
name: "default",
|
name: "default",
|
||||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.UseSwagger();
|
||||||
|
|
||||||
|
app.UseSwaggerUI(c =>
|
||||||
|
{
|
||||||
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample API");
|
||||||
|
});
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
41
WebInterface/Controllers/EmployeeControler.cs
Normal file
41
WebInterface/Controllers/EmployeeControler.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using vassago.Models;
|
||||||
|
|
||||||
|
namespace vassago.Controllers;
|
||||||
|
|
||||||
|
[Route("[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class EmployeeController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public IEnumerable<Account> Get()
|
||||||
|
{
|
||||||
|
return GetEmployeesDeatils();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public Account Get(Guid id)
|
||||||
|
{
|
||||||
|
return GetEmployeesDeatils().Find(e => e.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public Account Post([FromBody] Account employee)
|
||||||
|
{
|
||||||
|
// Write logic to insert employee data
|
||||||
|
return new Account();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Account> GetEmployeesDeatils()
|
||||||
|
{
|
||||||
|
return new List<Account>()
|
||||||
|
{
|
||||||
|
new Account()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,9 @@
|
|||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||||
<PackageReference Include="QRCoder" Version="1.4.2" />
|
<PackageReference Include="QRCoder" Version="1.4.2" />
|
||||||
<PackageReference Include="RestSharp" Version="110.2.0" />
|
<PackageReference Include="RestSharp" Version="110.2.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.6.2" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.6.2" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
|
||||||
<PackageReference Include="TwitchLib" Version="3.5.3" />
|
<PackageReference Include="TwitchLib" Version="3.5.3" />
|
||||||
<PackageReference Include="youtubedlsharp" Version="0.3.1" />
|
<PackageReference Include="youtubedlsharp" Version="0.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user