예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Security Vulnerability not fit for production
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddControllers()
            .ConfigureApiBehaviorOptions(option =>
            {
                option.SuppressMapClientErrors = true;
            });
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "UL Online Calculator ",
                    Version     = "1",
                    Description = "This API is used to evaluate Mathematical Expression.",
                    Contact     = new OpenApiContact()
                    {
                        Email = "*****@*****.**",
                        Name  = "Kumar Shantanu",
                        Url   = new Uri("http://uk.linkedin.com/in/shaan")
                    },
                    License = new OpenApiLicense()
                    {
                        Name = "MIT License",
                        Url  = new Uri("https://opensource.org/licenses/MIT")
                    }
                });

                // 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);
            });

            ServiceConfigurationManager.ConfigureAuthentication(services, Configuration);
            ServiceConfigurationManager.ConfigurePersistence(services, Configuration);
            ServiceConfigurationManager.ConfigureServiceLifeTime(services);
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Security Vulnerability not fit for production
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });
            services.AddControllers();
            services.AddHttpContextAccessor();
            ServiceConfigurationManager.ConfigureAuthentication(services, Configuration);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Publish News ",
                    Version     = "1",
                    Description = "Through this API you can Publish, Read News Articles and many more.",
                    Contact     = new OpenApiContact()
                    {
                        Email = "*****@*****.**",
                        Name  = "Kumar Shantanu",
                        Url   = new Uri("http://uk.linkedin.com/in/shaan")
                    },
                    License = new OpenApiLicense()
                    {
                        Name = "MIT License",
                        Url  = new Uri("https://opensource.org/licenses/MIT")
                    }
                });

                //todo Enable Xml document and get documents from them to Swagger
                //var xmlCommentsFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                //var xmlCommentsFullPath = Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);

                //setupAction.IncludeXmlComments(xmlCommentsFullPath);
            });
            ServiceConfigurationManager.ConfigurePersistence(services, Configuration);
            ServiceConfigurationManager.ConfigureServiceLifeTime(services);
        }