Exemple #1
0
        private void ConfigureMvc(IServiceCollection services)
        {
            services
            .AddMvcCore(config => {
                config.RespectBrowserAcceptHeader = true;
                config.ReturnHttpNotAcceptable    = true;
                //config.Filters.Add(new RequestBodyInsightsFilter(StatusCodes.Status400BadRequest));
            })
            .AddAuthorization()
            .AddFormatterMappings()
            .AddJsonFormatters()
            .AddXmlSerializerFormatters()
            .AddCors()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddVersionedApiExplorer(options => {
                options.GroupNameFormat           = "'v'VVV";
                options.SubstituteApiVersionInUrl = true;
            });

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

                VideoController.Convention(options);
            });
        }