145 lines
4.1 KiB
C#
145 lines
4.1 KiB
C#
using Microsoft.OpenApi.Models;
|
|
using Modules.Library.Application;
|
|
using Modules.Library.Database;
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
using Swashbuckle.AspNetCore.SwaggerUI;
|
|
using System.Reflection;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.AddServiceDefaults();
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddDatabase("mongodb://localhost:27017", "MyBookmarkDb");
|
|
|
|
builder.Services.AddApplicationServices();
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.Configure<SwaggerGenOptions>(options =>
|
|
{
|
|
options.SwaggerDoc("AnimeTitleV1", new OpenApiInfo
|
|
{
|
|
Title = "Title",
|
|
Description = "Description",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Example Contact",
|
|
Url = new Uri("https://example.com/contact")
|
|
},
|
|
License = new OpenApiLicense
|
|
{
|
|
Name = "Example License",
|
|
Url = new Uri("https://example.com/license")
|
|
},
|
|
Version = "v1"
|
|
});
|
|
/*
|
|
options.SwaggerDoc("AnimeSeasonV1", new OpenApiInfo
|
|
{
|
|
Title = "Season",
|
|
Description = "Description",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Example Contact",
|
|
Url = new Uri("https://example.com/contact")
|
|
},
|
|
License = new OpenApiLicense
|
|
{
|
|
Name = "Example License",
|
|
Url = new Uri("https://example.com/license")
|
|
},
|
|
Version = "v1"
|
|
});
|
|
|
|
options.SwaggerDoc("AnimeEpisodeV1", new OpenApiInfo
|
|
{
|
|
Title = "Episode",
|
|
Description = "Description",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Example Contact",
|
|
Url = new Uri("https://example.com/contact")
|
|
},
|
|
License = new OpenApiLicense
|
|
{
|
|
Name = "Example License",
|
|
Url = new Uri("https://example.com/license")
|
|
},
|
|
Version = "v1"
|
|
});
|
|
*/
|
|
|
|
options.SwaggerDoc("GenreV1", new OpenApiInfo
|
|
{
|
|
Title = "Genre",
|
|
Description = "Description",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Example Contact",
|
|
Url = new Uri("https://example.com/contact")
|
|
},
|
|
License = new OpenApiLicense
|
|
{
|
|
Name = "Example License",
|
|
Url = new Uri("https://example.com/license")
|
|
},
|
|
Version = "v1"
|
|
});
|
|
|
|
options.SwaggerDoc("LanguageV1", new OpenApiInfo
|
|
{
|
|
Title = "Language",
|
|
Description = "Description",
|
|
Contact = new OpenApiContact
|
|
{
|
|
Name = "Example Contact",
|
|
Url = new Uri("https://example.com/contact")
|
|
},
|
|
License = new OpenApiLicense
|
|
{
|
|
Name = "Example License",
|
|
Url = new Uri("https://example.com/license")
|
|
},
|
|
Version = "v1"
|
|
});
|
|
|
|
|
|
}).Configure<SwaggerUIOptions>(options =>
|
|
{
|
|
/*
|
|
options.SwaggerEndpoint("MediaContent/Anime/Title/swagger.json", "Anime Title V1");
|
|
//options.SwaggerEndpoint("MediaContent/Anime/Season/swagger.json", "Anime Season V1");
|
|
//options.SwaggerEndpoint("MediaContent/Anime/Episode/swagger.json", "Anime Episode V1");
|
|
options.SwaggerEndpoint("Dictionaries/Genre/swagger.json", "Genre V1");
|
|
options.SwaggerEndpoint("Dictionaries/Language/swagger.json", "Language V1");
|
|
*/
|
|
options.SwaggerEndpoint("AnimeTitleV1/swagger.json", "Anime Title V1");
|
|
//options.SwaggerEndpoint("MediaContent/Anime/Season/swagger.json", "Anime Season V1");
|
|
//options.SwaggerEndpoint("MediaContent/Anime/Episode/swagger.json", "Anime Episode V1");
|
|
options.SwaggerEndpoint("GenreV1/swagger.json", "Genre V1");
|
|
options.SwaggerEndpoint("LanguageV1/swagger.json", "Language V1");
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapDefaultEndpoints();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|