public AgreementsFixture() { FilteredControllerTypes.Add(typeof(Controllers.V1.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V2.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V3.AgreementsController)); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.Conventions.Add(new VersionByNamespaceConvention()); }); Configuration.Routes.MapHttpRoute( "VersionedQueryString", "api/{controller}/{accountId}", new { accountId = Optional }); Configuration.Routes.MapHttpRoute( "VersionedUrl", "v{apiVersion}/{controller}/{accountId}", new { accountId = Optional }, new { apiVersion = new ApiVersionRouteConstraint() }); Configuration.EnsureInitialized(); }
protected ConventionsAcceptanceTest() { var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) } }; FilteredControllerTypes.Add(typeof(ValuesController)); FilteredControllerTypes.Add(typeof(Values2Controller)); FilteredControllerTypes.Add(typeof(HelloWorldController)); FilteredControllerTypes.Add(typeof(HelloWorld2Controller)); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.Conventions.Controller <ValuesController>().HasApiVersion(1, 0); options.Conventions.Controller <Values2Controller>() .HasApiVersion(2, 0) .HasApiVersion(3, 0) .Action(c => c.GetV3()).MapToApiVersion(3, 0) .Action(c => c.GetV3(default(int))).MapToApiVersion(3, 0); options.Conventions.Controller <HelloWorldController>().HasDeprecatedApiVersion(1, 0); options.Conventions.Controller <HelloWorld2Controller>() .HasApiVersion(2, 0) .HasApiVersion(3, 0) .AdvertisesApiVersion(4, 0) .Action(c => c.GetV3()).MapToApiVersion(3, 0) .Action(c => c.GetV3(default(int))).MapToApiVersion(3, 0); }); Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.EnsureInitialized(); }
public AdvancedFixture() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(Orders2Controller)); FilteredControllerTypes.Add(typeof(Orders3Controller)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.ApiVersionReader = ApiVersionReader.Combine( new QueryStringApiVersionReader(), new HeaderApiVersionReader("api-version", "x-ms-version")); }); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration(supportedApiVersion: new ApiVersion(2, 0)), } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoute("odata", "api", models); Configuration.Routes.MapHttpRoute("orders", "api/{controller}/{key}", new { key = Optional }); Configuration.Formatters.Remove(Configuration.Formatters.XmlFormatter); Configuration.EnsureInitialized(); }
protected AdvancedAcceptanceTest() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(Orders2Controller)); FilteredControllerTypes.Add(typeof(Orders3Controller)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.ApiVersionReader = ApiVersionReader.Combine( new QueryStringApiVersionReader(), new HeaderApiVersionReader("api-version", "x-ms-version")); }); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(), ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration(supportedApiVersion: new ApiVersion(2, 0)) } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoutes("odata", "api", models, builder => builder.AddService(Singleton, typeof(ODataUriResolver), sp => TestUriResolver)); Configuration.Routes.MapHttpRoute("orders", "api/{controller}/{key}", new { key = Optional }); Configuration.EnsureInitialized(); }
protected ConventionsAcceptanceTest() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.Conventions.Controller <OrdersController>() .HasApiVersion(1, 0); options.Conventions.Controller <PeopleController>() .HasApiVersion(1, 0) .HasApiVersion(2, 0) .Action(c => c.Patch(default(int), null, null)).MapToApiVersion(2, 0); options.Conventions.Controller <People2Controller>() .HasApiVersion(3, 0); }); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(), ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration() } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoutes("odata", "api", models); Configuration.MapVersionedODataRoutes("odata-bypath", "v{apiVersion}", models); Configuration.EnsureInitialized(); }
public BasicFixture() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); FilteredControllerTypes.Add(typeof(CustomersController)); FilteredControllerTypes.Add(typeof(WeatherForecastsController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration(), new CustomerModelConfiguration(), new WeatherForecastModelConfiguration(), } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoute("odata", "api", models); Configuration.MapVersionedODataRoute("odata-bypath", "v{apiVersion}", models); Configuration.EnsureInitialized(); }
protected BasicAcceptanceTest() { var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) } }; FilteredControllerTypes.Add(typeof(ValuesController)); FilteredControllerTypes.Add(typeof(Values2Controller)); FilteredControllerTypes.Add(typeof(HelloWorldController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.EnsureInitialized(); }
public MediaTypeNegotiationFixture() { FilteredControllerTypes.Add(typeof(ValuesController)); FilteredControllerTypes.Add(typeof(Values2Controller)); FilteredControllerTypes.Add(typeof(HelloWorldController)); Configuration.AddApiVersioning( options => { options.ApiVersionReader = new MediaTypeApiVersionReader(); options.AssumeDefaultVersionWhenUnspecified = true; options.ApiVersionSelector = new CurrentImplementationApiVersionSelector(options); options.ReportApiVersions = true; }); Configuration.MapHttpAttributeRoutes(); Configuration.EnsureInitialized(); }
public BasicFixture() { var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) } }; FilteredControllerTypes.Add(typeof(ValuesController)); FilteredControllerTypes.Add(typeof(Values2Controller)); FilteredControllerTypes.Add(typeof(HelloWorldController)); FilteredControllerTypes.Add(typeof(PingController)); FilteredControllerTypes.Add(typeof(OverlappingRouteTemplateController)); FilteredControllerTypes.Add(typeof(OrdersController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.EnsureInitialized(); }
private void ConfigureAgreements() { FilteredControllerTypes.Add(typeof(Controllers.V1.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V2.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V3.AgreementsController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); Configuration.Routes.MapHttpRoute( "VersionedQueryString", "api/{controller}/{accountId}", new { accountId = Optional }); Configuration.Routes.MapHttpRoute( "VersionedUrl", "v{apiVersion}/{controller}/{accountId}", new { accountId = Optional }, new { apiVersion = new ApiVersionRouteConstraint() }); }
void ConfigureOrders() { FilteredControllerTypes.Add(typeof(Controllers.V1.OrdersController)); FilteredControllerTypes.Add(typeof(Controllers.V2.OrdersController)); FilteredControllerTypes.Add(typeof(Controllers.V3.OrdersController)); var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) } }; Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.Conventions.Add(new VersionByNamespaceConvention()); }); }
private void ConfigureHellWorld() { FilteredControllerTypes.Add(typeof(Controllers.V1.HelloWorldController)); FilteredControllerTypes.Add(typeof(Controllers.V2.HelloWorldController)); FilteredControllerTypes.Add(typeof(Controllers.V3.HelloWorldController)); var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) } }; Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.DefaultApiVersion = new ApiVersion(2, 0); options.AssumeDefaultVersionWhenUnspecified = true; }); }
protected ByNamespaceAcceptanceTest() { FilteredControllerTypes.Add(typeof(Controllers.V1.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V2.AgreementsController)); FilteredControllerTypes.Add(typeof(Controllers.V3.AgreementsController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); Configuration.Routes.MapHttpRoute( "VersionedQueryString", "api/{controller}/{accountId}", new { accountId = Optional }); Configuration.Routes.MapHttpRoute( "VersionedUrl", "v{apiVersion}/{controller}/{accountId}", new { accountId = Optional }, new { apiVersion = new ApiVersionRouteConstraint() }); Configuration.EnsureInitialized(); }
protected BasicAcceptanceTest() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelBuilderFactory = () => new ODataConventionModelBuilder().EnableLowerCamelCase(), ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration() } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoutes("odata", "api", models); Configuration.MapVersionedODataRoutes("odata-bypath", "v{apiVersion}", models); Configuration.EnsureInitialized(); }
public HelloWorldFixture() { FilteredControllerTypes.Add(typeof(Controllers.V1.HelloWorldController)); FilteredControllerTypes.Add(typeof(Controllers.V2.HelloWorldController)); FilteredControllerTypes.Add(typeof(Controllers.V3.HelloWorldController)); var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof(ApiVersionRouteConstraint) }, }; Configuration.MapHttpAttributeRoutes(constraintResolver); Configuration.AddApiVersioning( options => { options.ReportApiVersions = true; options.DefaultApiVersion = new ApiVersion(2, 0); options.AssumeDefaultVersionWhenUnspecified = true; options.Conventions.Add(new VersionByNamespaceConvention()); }); Configuration.EnsureInitialized(); }
protected BasicAcceptanceTest() { FilteredControllerTypes.Add(typeof(OrdersController)); FilteredControllerTypes.Add(typeof(PeopleController)); FilteredControllerTypes.Add(typeof(People2Controller)); FilteredControllerTypes.Add(typeof(CustomersController)); Configuration.AddApiVersioning(options => options.ReportApiVersions = true); var modelBuilder = new VersionedODataModelBuilder(Configuration) { ModelConfigurations = { new PersonModelConfiguration(), new OrderModelConfiguration(), new CustomerModelConfiguration(), } }; var models = modelBuilder.GetEdmModels(); Configuration.MapVersionedODataRoutes("odata", "api", models, builder => builder.AddService(Singleton, typeof(ODataUriResolver), sp => TestUriResolver)); Configuration.MapVersionedODataRoutes("odata-bypath", "v{apiVersion}", models, builder => builder.AddService(Singleton, typeof(ODataUriResolver), sp => TestUriResolver)); Configuration.EnsureInitialized(); }