This commit is contained in:
2020-09-02 20:53:34 -04:00
parent 85d99d2615
commit d06925204d
38 changed files with 913 additions and 679 deletions

View File

@@ -1,11 +1,16 @@
using Microsoft.AspNetCore.Builder;
using AutoMapper;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using PartSource.Api.Formatters;
using PartSource.Data;
using PartSource.Data.AutoMapper;
using PartSource.Services;
using System.IO;
namespace PartSource.Api
{
@@ -23,10 +28,20 @@ namespace PartSource.Api
{
services.AddMvc(options =>
{
options.OutputFormatters.Add(new LiquidTemplateOutputFormatter());
options.OutputFormatters.RemoveType(typeof(StringOutputFormatter));
options.EnableEndpointRouting = false;
});
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v2", new OpenApiInfo { Title = "Partsource/WHI Integration API", Version = "v2" });
c.IncludeXmlComments(Path.Combine(System.AppContext.BaseDirectory, "PartSource.Api.xml"));
c.IncludeXmlComments(Path.Combine(System.AppContext.BaseDirectory, "PartSource.Data.xml"));
});
services.AddAutoMapper(typeof(PartSourceProfile));
services.AddTransient<PartService>();
services.AddTransient<NexpartService>();
services.AddTransient<SecurityService>();
@@ -58,7 +73,14 @@ namespace PartSource.Api
app.UseCors("Default");
// app.UseExceptionHandler("/Error");
app.UseSwagger();
app.UseReDoc(c =>
{
c.SpecUrl = "/swagger/v2/swagger.json";
c.ExpandResponses(string.Empty);
});
// app.UseExceptionHandler("/Error");
// app.UseHttpsRedirection();
app.UseMvc();
}