Example #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureDependenciesRepository(services);
     services.AddMediatR(typeof(Startup));
     services.AddControllers();
 }
Example #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureDependenciesRepository(services);
     services.AddControllers();
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new OpenApiInfo
         {
             Version        = "v1",
             Title          = "Curso de API com AspNetCore 3.1 - Na Prática",
             Description    = "Arquitetura DDD",
             TermsOfService = new Uri("http://www.mfrinfo.com.br"),
             Contact        = new OpenApiContact
             {
                 Name  = "Marcos Fabricio Rosa",
                 Email = "*****@*****.**",
                 Url   = new Uri("http://www.mfrinfo.com.br")
             },
             License = new OpenApiLicense
             {
                 Name = "Termo de Licença de Uso",
                 Url  = new Uri("http://www.mfrinfo.com.br")
             }
         });
     });
 }
Example #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <IAuthorService, AuthorService>();
            ConfigureRepository.ConfDependenciesRepository(services);
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddMvc(option => option.EnableEndpointRouting = false)
            .AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);

            services.AddHttpClient <HttpClientAuthorsAPI>(client => {
                client.BaseAddress = new Uri("https://localhost:44392/api/authors/");
            });
            services.AddHttpClient <HttpClientBookAPI>(client => {
                client.BaseAddress = new Uri("https://localhost:44392/api/books/");
            });
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <BookView, Book>();
            });
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddControllersWithViews();
            services.AddRazorPages();
        }
Example #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title   = "API AspNetCore"
                });
            }
                                   );
        }
Example #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);       //fazendo injeção de dependencia em crosscutting/dependencyinjection/configureservice
            ConfigureRepository.ConfigureDependenciesRepository(services); //injeção de dependencia

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title          = "API whith DDD",
                    Version        = "v1",
                    Description    = "Aplicação em DDD",
                    TermsOfService = new Uri("https://maxgi.com.br/termoapiddd"),
                    Contact        = new OpenApiContact
                    {
                        Name  = "Maxsweel Rodrigues de Souza",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://maxgi.com.br")
                    },
                    License = new OpenApiLicense
                    {
                        Name = "Termo de licença",
                        Url  = new Uri("https://maxgi.com.br/termolicenca")
                    }
                });
            });


            /*
             * Configuração padrão Swagger
             * services.AddSwaggerGen(c =>
             * {
             *  c.SwaggerDoc("v1", new OpenApiInfo { Title = "Application", Version = "v1" });
             * });*/
        }
Example #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string connectionString = Configuration.GetConnectionString("ConnectionString");

            ConfigureRepository.ConfigureDependenciesService(services, connectionString);
            ConfigureService.ConfigureDependenciesService(services);

            // Configuration JTW
            ConfigureJwt.ConfigureDependenciesJwt(services, Configuration);
            // End Configuration JTW

            // Configuration MailJet
            ConfigureMailJet.ConfigureDependecieMailJet(services, Configuration);
            // End Configuration MailJet

            services.AddControllers().AddNewtonsoftJson(op => op.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = "Me agenda aí - API",
                    Description    = "API para gerenciamento da aplicação me agenda aí",
                    TermsOfService = new Uri("https://github.com/Maarkis/MeAgendaAiAPI"),
                    Contact        = new OpenApiContact
                    {
                        Name  = "Jean Markis - Manoela Viana - Vitória Simões",
                        Email = "[email protected];[email protected];[email protected]",
                        Url   = new Uri("https://github.com/Maarkis/MeAgendaAiAPI"),
                    },
                    License = new OpenApiLicense
                    {
                        Name = "Use under LICX",
                        Url  = new Uri("https://example.com/license"),
                    }
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "Token JWT",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme {
                            Reference = new OpenApiReference
                            {
                                Id   = "Bearer",
                                Type = ReferenceType.SecurityScheme
                            }
                        }, new List <string>()
                    }
                });
            });
        }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddCors(o => o.AddPolicy("MyPolicy", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); }));
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureServices(services);
     services.AddControllers();
 }
Example #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependeciesService(services);
            ConfigureRepository.ConfigureDependeciesRepository(services);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Example #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Wevo API",
                    Description = "Desafio",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Kako",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://github.com/KakoF")
                    }
                });
            });
        }
Example #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            services.AddCors(o =>
            {
                o.AddDefaultPolicy(
                    b =>
                {
                    b.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
                }
                    );
            });
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Loja Virutal",
                    Version     = "v1",
                    Description = "Api para loja virtual usando arquitetura DDD e TDD",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Jonathan Vegas Peixoto",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://jonathanvegas.tech")
                    }
                }

                             );
            });
        }
Example #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesService(services);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DomainModelMapping());
                cfg.AddProfile(new DtoModelMapping());
                cfg.AddProfile(new DomainDtoMapping());
            });

            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddCors(options =>
            {
                options.AddPolicy(name: AllowOrigins, builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers();
        }
Example #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new OpenApiInfo
                {
                    Title       = "MANAGER OPEN ERP",
                    Version     = "v1",
                    Description = "API REST criada com o ASP.NET Core para Gestão de OPEN ERP",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Apeninos.COM",
                        Email = string.Empty,
                        Url   = new Uri("https://apeninos.com/")
                    }
                });


                // Set the comments path for the Swagger JSON and UI.
            });

            services.AddControllers();
        }
Example #13
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureDependenciesRepository(services);
     services.AddControllers();
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new OpenApiInfo
         {
             Version        = "v1",
             Title          = "Api",
             Description    = "Arquitura DDD",
             TermsOfService = new Uri("http://www.ivanlg.epizy.com"),//não esta pronto o portifólio!
             Contact        = new OpenApiContact
             {
                 Name  = "Ivan Luiz Gessi",
                 Email = "*****@*****.**",
                 Url   = new Uri("http://www.ivanlg.epizy.com")
             },
             License = new OpenApiLicense
             {
                 Name = "Termo de Licença de Uso",
                 Url  = new Uri("http://www.ivanlg.epizy.com")
             }
         });
     });
 }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfiguracaoTesteIntegracao();

            services.AddControllers();

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            ConfigureHelper.ConfigureDependenciesHelper(services);

            services.AddSingleton(ConfigurationMapper());

            SigningConfigurations signingConfigurations = new SigningConfigurations();

            services.AddSingleton(signingConfigurations);

            TokenConfigurations tokenConfigurations = BuilderTokenConfigurations();

            services.AddAuthentication(ConfigurationAddAuthentication()).AddJwtBearer(ConfigurationAddJwtBearer(signingConfigurations, tokenConfigurations));

            // Ativa o uso do token como forma de autorizar o acesso
            // a recursos deste projeto
            services.AddAuthorization(ConfigurationAddAuthorization());

            services.AddSingleton(tokenConfigurations);

            services.AddSwaggerGen(c => ConfigurationSwagger(c));
        }
Example #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services, Configuration);
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
            services.AddControllers(options =>
            {
                options.Filters.Add(typeof(DomainExceptionFilter));
            });

            services.AddSwaggerGen(a =>
            {
                a.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
                a.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Desafio técnico FULLSTACK",
                    Description = "Arquitetura DDD - TDD",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Lucas Ost",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://www.linkedin.com/in/lucasost/")
                    }
                });
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureRepository.ConfigureDependenciesRepository(services);
            ConfigureService.ConfigureDependenciesService(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DTOToModelProfile());
                cfg.AddProfile(new EntityToDTOProfile());
                cfg.AddProfile(new EntityToModelProfile());
            });
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Market Api",
                    Version     = "v1",
                    Description = "Market Api with architecture DDD",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Roberta Suélen Rodrigues Alves",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://www.linkedin.com/in/roberta-su%C3%A9len-rodrigues-alves-223733116")
                    }
                });
            });
        }
Example #17
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <Context>(options => options.UseNpgsql(Configuration.GetConnectionString("DeliverItContext")));

            services.AddControllers();

            ConfigureRepository.ConfigureDependecyService(services);
            ConfigureService.ConfigureDependencysService(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "test_deliverit", Version = "v1"
                });
            });
        }
Example #18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "API DotNet Core 2.2",
                    Version     = "v1",
                    Description = "Modelo de API DDD com DotNetCore 3.0",
                    Contact     = new Contact
                    {
                        Name = "Joice M Cardoso Lopes"
                    }
                });
            });

            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Example #19
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title   = "Prova NaPista",
                    Contact = new OpenApiContact
                    {
                        Name  = "Raul Rodrigo Silva de Andrade",
                        Email = "*****@*****.**",
                    }
                });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
Example #20
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Application", Version = "v1"
                });
            });

            services.AddDbContext <MyContext>(opt => opt.UseInMemoryDatabase("dbapi").ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning)));

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
Example #21
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(name: MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod();
                });
            });

            if (_environment.IsEnvironment("Test"))
            {
                Environment.SetEnvironmentVariable("Connection", Configuration["ConnectionStringsTest:Connection"]);
            }
            else
            {
                Environment.SetEnvironmentVariable("Connection", Configuration["ConnectionStrings:Connection"]);
            }

            Environment.SetEnvironmentVariable("DATABASE", Configuration["ConnectionStrings:DataBase"]);
            Environment.SetEnvironmentVariable("MIGRATION", Configuration["ConnectionStrings:Migration"]);
            Environment.SetEnvironmentVariable("Audience", Configuration["Token:Audience"]);
            Environment.SetEnvironmentVariable("Issuer", Configuration["Token:Issuer"]);
            Environment.SetEnvironmentVariable("Seconds", Configuration["Token:Seconds"]);
            Environment.SetEnvironmentVariable("YIELD_VALUE", Configuration["Configuration:yieldValue"]);

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            ConfigureMapper(services);
            ConfigureAuthentication(services);
            services.AddControllers();
            ConfigureSwagger(services);
        }
Example #22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureRepository.ConfigureDependenciesRepository(services, Configuration);
            ConfigureService.ConfigureDependenciesService(services);

            services.AddAutoMapper();

            services.AddHostedService <QuartzHostedService>();

            services.AddControllers();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "API Open Food",
                    Description = "Consumo de dados do Open Food Facts",
                    Contact     = new OpenApiContact
                    {
                        Name = "Marcos Davi"
                    }
                });
            });
        }
Example #23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Api Restaurant App",
                    Description = "Api of Restaurant Application",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Matheus de Almeida Oliveira",
                        Email = "*****@*****.**"
                    }
                });
            });

            services.AddCors(options =>
            {
                options.AddPolicy("EnableCORS", builder =>
                {
                    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().Build();
                });
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            ConfigureDataBase.ConfigureDependenciesDataBase(services, Configuration.GetConnectionString("aplicacoesDistribuidas"));

            // Configuration Mapper
            ConfigureMapper.ConfigureDependencieMapper(services);

            // Configuration JTW
            ConfigureJwt.ConfigureDependenciesJwt(services, Configuration);

            services.AddControllers();

            // Configuration Swagger
            services.AddSwaggerGen(swaggerGen =>
            {
                swaggerGen.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = "API - Aplicação distribuídas",
                    Description    = "API para gerenciamento de CRUD de produto e usuários",
                    TermsOfService = new Uri("https://github.com/Maarkis/AplicacoesDistribuidasAPI"),
                    Contact        = new OpenApiContact
                    {
                        Name  = "Jean Markis",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://github.com/Maarkis/AplicacoesDistribuidasAPI"),
                    }
                });

                swaggerGen.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "Token JWT",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                swaggerGen.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme {
                            Reference = new OpenApiReference
                            {
                                Id   = "Bearer",
                                Type = ReferenceType.SecurityScheme
                            }
                        }, new List <string>()
                    }
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                swaggerGen.IncludeXmlComments(xmlPath);
            });

            // End Configuration Swagger
        }
Example #25
0
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureDatabase.ConfigureDependencyDatabases(services);
            ConfigureService.ConfigureDependencyServices(services);
            ConfigureRepository.ConfigureDependencyRepositories(services);
            ConfigureMapping.ConfigureDependencyMapping(services);

            var signingConfiguration = new SigningConfiguration();
            var tokenConfiguration   = Configuration.GetSection("Token").Get <TokenConfiguration>();

            services.AddSingleton(signingConfiguration);
            services.AddSingleton(tokenConfiguration);

            services.AddAuthentication(options => {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options => {
                var validation = options.TokenValidationParameters;
                validation.IssuerSigningKey         = signingConfiguration.Key;
                validation.ValidAudience            = tokenConfiguration.Audience;
                validation.ValidIssuer              = tokenConfiguration.Issuer;
                validation.ValidateIssuerSigningKey = true;
                validation.ValidateLifetime         = true;
                validation.ClockSkew = TimeSpan.Zero;
            });

            services.AddAuthorization(options => {
                options.DefaultPolicy = new AuthorizationPolicyBuilder()
                                        .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                                        .RequireAuthenticatedUser()
                                        .Build();
            });

            services.AddSwaggerGen(config =>
            {
                config.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
                config.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme {
                    In          = ParameterLocation.Header,
                    Description = "Token jwt",
                    Name        = "Authorization",
                    Type        = SecuritySchemeType.ApiKey
                });
                config.AddSecurityRequirement(new OpenApiSecurityRequirement {
                    {
                        new OpenApiSecurityScheme {
                            Reference = new OpenApiReference {
                                Id   = "Bearer",
                                Type = ReferenceType.SecurityScheme
                            }
                        },
                        new string[0]
                    }
                });
            });

            services.AddControllers();
        }
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureContext.ConfigureContextDependencies(services);
     ConfigureTransaction.ConfigureTransactionDependencies(services);
     ConfigureRepository.ConfigureRepositoryDependencies(services);
     ConfigureService.ConfigureServiceDependencies(services);
     services.AddControllers();
 }
Example #27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);

            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddControllersWithViews();
        }
Example #28
0
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureServices(services);
            ConfigureRepository.ConfigureServices(services);

            //MVC
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest);
        }
Example #29
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureDepenciesRepository(services);
     services.AddControllersWithViews();
     // In production, the Angular files will be served from this directory
     services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; });
 }
Example #30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Injeção de Dependências
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesService(services);

            services.AddControllers();
        }