Exemple #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(m => { m.EnableEndpointRouting = false; })
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            services.AddApiVersioning(s =>
            {
                s.DefaultApiVersion = new ApiVersion(1, 0);
                s.ReportApiVersions = true;
                s.AssumeDefaultVersionWhenUnspecified = true;
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title   = "Calculadora de Juros - Web API",
                    Version = "v1"
                });
            });

            services.AddHttpClient("taxaDeJurosV1", c => { c.BaseAddress = new Uri(_config["UrlDaApiDeTaxasDeJurosV1"]); })
            .AddPolicyHandler(GetRetryPolicy());

            services.AddHttpClient("taxaDeJurosV2", c => { c.BaseAddress = new Uri(_config["UrlDaApiDeTaxasDeJurosV2"]); })
            .AddPolicyHandler(GetRetryPolicy());

            IocServices.Register(services);
            IocDomain.Register(services);
        }
Exemple #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <TaxasDeJurosContext>(opt => opt.UseInMemoryDatabase("TaxaDejuros"));

            services.AddMvc(m => { m.EnableEndpointRouting = false; })
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            services.AddApiVersioning(s =>
            {
                s.DefaultApiVersion = new ApiVersion(1, 0);
                s.ReportApiVersions = true;
                s.AssumeDefaultVersionWhenUnspecified = true;

                s.Conventions.Controller <TaxaDeJurosV1Controller>().HasApiVersion(new ApiVersion(1, 0));
                s.Conventions.Controller <TaxaDeJurosV2Controller>().HasApiVersion(new ApiVersion(2, 0));
            });

            services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV");

            services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerOptions>();
            services.AddSwaggerGen();

            IocServices.Register(services);
            IocDomain.Register(services);
            IocData.Register(services);
        }
Exemple #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <TasklistDbContext>(options =>
                                                      options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddOData();
            services.AddControllers(mvcOptions =>
                                    mvcOptions.EnableEndpointRouting = false);

            services.AddMvc().AddFluentValidation();

            IocService.Register(services);
            IocDomain.Register(services);

            ConfigureMappingService(services);
            ConfigureAuthenticationService(services);
            ConfigureSwaggerService(services);
        }