#pragma warning disable SA1614 // Element parameter documentation must have text #pragma warning disable SA1616 // Element return value documentation must have text /// <summary> /// Adds Evelyn Management Rest API services to the specified IServiceCollection /// </summary> /// <param name="services"></param> /// <param name="options">An Action<ApiRegistration> to configure the provided ApiRegistration</param> /// <returns></returns> public static IServiceCollection AddEvelynApi(this IServiceCollection services, Action <EvelynApiOptions> options) #pragma warning restore SA1616 // Element return value documentation must have text #pragma warning restore SA1614 // Element parameter documentation must have text { var managementApiInfo = new Swashbuckle.AspNetCore.Swagger.Info() { Version = "v0.1", Title = "Evelyn Management API", Description = "Management API for Evelyn", }; var clientApiInfo = new Swashbuckle.AspNetCore.Swagger.Info() { Version = "client-api", Title = "Evelyn Client API", Description = "Client API for Evelyn", }; services.AddSwaggerGen(config => { config.SwaggerDoc("management-api", managementApiInfo); config.SwaggerDoc("client-api", clientApiInfo); config.CustomSchemaIds(type => type.FullName); }); options.Invoke(new EvelynApiOptions(services)); return(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Register the Swagger generator, defining 1 or more Swagger documents var swaggerInfo = new Swashbuckle.AspNetCore.Swagger.Info(); swaggerInfo.Title = "Microservice Template"; services.AddSwaggerGen(c => { c.SwaggerDoc("v1", swaggerInfo); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(RequestPostProcessorBehavior<,>)); services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CustomPipelineBehavior<,>)); services.AddMediatR(); services.AddMvc(options => { options.Filters.Add<HttpGlobalExceptionFilter>(); options.Filters.Add<ValidateModelFilter>(); }) .AddFluentValidation(fv => { fv.RegisterValidatorsFromAssemblyContaining<AssemblyMarker>(); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddAutoMapper(); services.AddDbContext<TasksDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("TasksDb")); }); var context = services.BuildServiceProvider() .GetService<TasksDbContext>(); context.Database.Migrate(); services.AddCors(); services.AddSwaggerGen(c => { var swaggerInfo = new Swashbuckle.AspNetCore.Swagger.Info { Version = "0.1.0", Title = "Tasks API", Description = "Tasks API web methods." }; c.SwaggerDoc("v1", swaggerInfo); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <duca_gtwContext>(options => { options.UseMySql(Configuration.GetConnectionString("DefaultConnection")); }); //services.AddTransient<ILojistaRepository, LojistaRepository>(); services.AddMvc(); //swagger Swashbuckle.AspNetCore.Swagger.Info sinfo = new Swashbuckle.AspNetCore.Swagger.Info(); sinfo.Title = "APIDucaGateWay"; sinfo.Version = "v1"; services.AddSwaggerGen(c => c.SwaggerDoc("v1", sinfo)); }