예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddResponseCompression();
            services.AddCors(builder => builder.AddDefaultPolicy(policyBuilder => policyBuilder.AllowAnyOrigin()));
            IMvcCoreBuilder mvc = services.AddMvcCore();

            mvc.AddApiExplorer();
            mvc.SetCompatibilityVersion(CompatibilityVersion.Latest);
            mvc.AddFormatterMappings();
            mvc.AddJsonFormatters();
            mvc.AddJsonOptions(
                options => {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                options.SerializerSettings.Formatting       = Formatting.Indented;
            }
                );

            services.AddSignalR();
            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Version     = "v1",
                    Title       = "Home assistant API",
                    Description = $"Documentation for {Core.AssistantName} api endpoints.",
                    Contact     = new OpenApiContact()
                    {
                        Name  = "Arun Prakash",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://github.com/SynergYFTW/HomeAssistant")
                    },
                    License = new OpenApiLicense()
                    {
                        Name = "MIT License",
                        Url  = new Uri("https://github.com/SynergYFTW/HomeAssistant/blob/master/LICENSE")
                    }
                });
            });
        }