swagger added
This commit is contained in:
@@ -20,12 +20,9 @@ namespace WatchIt
|
|||||||
{
|
{
|
||||||
_builder = WebApplication.CreateBuilder(args);
|
_builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Logging
|
ConfigureLogging();
|
||||||
_builder.Logging.ClearProviders();
|
ConfigureDatabase();
|
||||||
_builder.Logging.AddConsole();
|
ConfigureWebAPI();
|
||||||
|
|
||||||
// Database
|
|
||||||
_builder.Services.AddDbContext<DatabaseContext>(x => x.UseNpgsql(_builder.Configuration.GetConnectionString("Default")), ServiceLifetime.Singleton);
|
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
_builder.Services.AddRazorComponents()
|
_builder.Services.AddRazorComponents()
|
||||||
@@ -40,12 +37,29 @@ namespace WatchIt
|
|||||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app.UseSwagger(x =>
|
||||||
|
{
|
||||||
|
x.RouteTemplate = "api/swagger/{documentname}/swagger.json";
|
||||||
|
});
|
||||||
|
app.UseSwaggerUI(x =>
|
||||||
|
{
|
||||||
|
x.SwaggerEndpoint("/api/swagger/v1/swagger.json", "WatchIt API");
|
||||||
|
x.RoutePrefix = "api/swagger";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseAntiforgery();
|
app.UseAntiforgery();
|
||||||
|
|
||||||
|
app.UseAuthentication();
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
@@ -53,5 +67,29 @@ namespace WatchIt
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected static void ConfigureLogging()
|
||||||
|
{
|
||||||
|
_builder.Logging.ClearProviders();
|
||||||
|
_builder.Logging.AddConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void ConfigureDatabase()
|
||||||
|
{
|
||||||
|
_builder.Services.AddDbContext<DatabaseContext>(x => x.UseNpgsql(_builder.Configuration.GetConnectionString("Default")), ServiceLifetime.Singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void ConfigureWebAPI()
|
||||||
|
{
|
||||||
|
_builder.Services.AddControllers();
|
||||||
|
_builder.Services.AddEndpointsApiExplorer();
|
||||||
|
_builder.Services.AddSwaggerGen();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,6 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="WebAPI\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
||||||
@@ -23,6 +19,10 @@
|
|||||||
<PackageReference Include="Npgsql" Version="8.0.2" />
|
<PackageReference Include="Npgsql" Version="8.0.2" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
16
WatchIt/WebAPI/AccountsController.cs
Normal file
16
WatchIt/WebAPI/AccountsController.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace WatchIt.WebAPI
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/accounts")]
|
||||||
|
public class AccountsController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
[Route("create-account")]
|
||||||
|
public async Task CreateAccount()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user