├── .config └── dotnet-tools.json ├── .devcontainer ├── Dockerfile ├── devcontainer.json └── scripts │ └── container-creation.sh ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── 10_bug_report.yml │ ├── 20_feature_request.yml │ ├── 30_api_proposal.md │ └── config.yml ├── dependabot.yml ├── pull_request_template.md ├── signatures │ └── cla.json └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .vscode ├── extensions.json ├── launch.json ├── project.code-snippets ├── settings.json └── tasks.json ├── .vsconfig ├── LICENSE.txt ├── README.md ├── asp.sln ├── azure-pipelines.yml ├── build ├── acceptance.xunit.runner.json ├── assembly-info.props ├── assets.msbuildproj ├── code-analysis.props ├── common.props ├── file-version.targets ├── icon.png ├── key.snk ├── nuget.props ├── nuget.targets ├── resource.targets ├── signing.props ├── steps-ci.yml ├── steps-release.yml ├── stylecop.json ├── test.props ├── test.targets └── xunit.runner.json ├── docs └── CONTRIBUTING.md ├── examples ├── .editorconfig ├── AspNet │ ├── Directory.Build.props │ ├── OData │ │ ├── AdvancedODataWebApiExample │ │ │ ├── AdvancedODataWebApiExample.csproj │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── Orders2Controller.cs │ │ │ │ ├── Orders3Controller.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── Program.cs │ │ │ └── Startup.cs │ │ ├── BasicODataWebApiExample │ │ │ ├── BasicODataWebApiExample.csproj │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── Program.cs │ │ │ └── Startup.cs │ │ ├── ConventionsODataWebApiExample │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── ConventionsODataWebApiExample.csproj │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── Program.cs │ │ │ └── Startup.cs │ │ ├── OpenApiODataWebApiExample │ │ │ ├── ApiControllerExtensions.cs │ │ │ ├── Configuration │ │ │ │ ├── AllConfigurations.cs │ │ │ │ ├── ApiVersions.cs │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ ├── PersonModelConfiguration.cs │ │ │ │ ├── ProductConfiguration.cs │ │ │ │ └── SupplierConfiguration.cs │ │ │ ├── EnumerableExtensions.cs │ │ │ ├── FunctionsController.cs │ │ │ ├── HttpRequestMessageExtensions.cs │ │ │ ├── Models │ │ │ │ ├── Address.cs │ │ │ │ ├── LineItem.cs │ │ │ │ ├── Order.cs │ │ │ │ ├── Person.cs │ │ │ │ ├── Product.cs │ │ │ │ └── Supplier.cs │ │ │ ├── ODataExtensions.cs │ │ │ ├── OpenApiODataWebApiExample.csproj │ │ │ ├── Program.cs │ │ │ ├── Startup.cs │ │ │ ├── SwaggerDefaultValues.cs │ │ │ ├── V1 │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── V2 │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ └── V3 │ │ │ │ ├── AcmeController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── PeopleController.cs │ │ │ │ ├── ProductsController.cs │ │ │ │ └── SuppliersController.cs │ │ └── SomeOpenApiODataWebApiExample │ │ │ ├── Book.cs │ │ │ ├── BooksController.cs │ │ │ ├── Program.cs │ │ │ ├── SomeOpenApiODataWebApiExample.csproj │ │ │ ├── Startup.cs │ │ │ └── SwaggerDefaultValues.cs │ ├── Startup.Newtonsoft.cs │ └── WebApi │ │ ├── BasicWebApiExample │ │ ├── BasicWebApiExample.csproj │ │ ├── Controllers │ │ │ ├── HelloWorldController.cs │ │ │ ├── Values2Controller.cs │ │ │ └── ValuesController.cs │ │ ├── Program.cs │ │ └── Startup.cs │ │ ├── ByNamespaceWebApiExample │ │ ├── ByNamespaceWebApiExample.csproj │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── V1 │ │ │ ├── Controllers │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ │ ├── Agreement.cs │ │ │ │ └── Order.cs │ │ ├── V2 │ │ │ ├── Controllers │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ │ ├── Agreement.cs │ │ │ │ └── Order.cs │ │ └── V3 │ │ │ ├── Controllers │ │ │ ├── AgreementsController.cs │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ ├── Agreement.cs │ │ │ └── Order.cs │ │ ├── ConventionsWebApiExample │ │ ├── Controllers │ │ │ ├── HelloWorldController.cs │ │ │ ├── Values2Controller.cs │ │ │ └── ValuesController.cs │ │ ├── ConventionsWebApiExample.csproj │ │ ├── Program.cs │ │ └── Startup.cs │ │ └── OpenApiWebApiExample │ │ ├── OpenApiWebApiExample.csproj │ │ ├── Program.cs │ │ ├── Startup.cs │ │ ├── SwaggerDefaultValues.cs │ │ ├── V1 │ │ ├── Controllers │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ └── Models │ │ │ ├── Order.cs │ │ │ └── Person.cs │ │ ├── V2 │ │ ├── Controllers │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ └── Models │ │ │ ├── Order.cs │ │ │ └── Person.cs │ │ └── V3 │ │ ├── Controllers │ │ ├── OrdersController.cs │ │ └── PeopleController.cs │ │ └── Models │ │ ├── Order.cs │ │ └── Person.cs ├── AspNetCore │ ├── Directory.Build.props │ ├── OData │ │ ├── Directory.Build.props │ │ ├── ODataAdvancedExample │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── Orders2Controller.cs │ │ │ │ ├── Orders3Controller.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── ODataAdvancedExample.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ └── appsettings.json │ │ ├── ODataBasicExample │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── ODataBasicExample.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ └── appsettings.json │ │ ├── ODataConventionsExample │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Controllers │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── Models │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── ODataConventionsExample.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ └── appsettings.json │ │ ├── ODataOpenApiExample │ │ │ ├── Configuration │ │ │ │ ├── AllConfigurations.cs │ │ │ │ ├── ApiVersions.cs │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ ├── PersonModelConfiguration.cs │ │ │ │ ├── ProductConfiguration.cs │ │ │ │ └── SupplierConfiguration.cs │ │ │ ├── ConfigureSwaggerOptions.cs │ │ │ ├── EnumerableExtensions.cs │ │ │ ├── FunctionsController.cs │ │ │ ├── Models │ │ │ │ ├── Address.cs │ │ │ │ ├── LineItem.cs │ │ │ │ ├── Order.cs │ │ │ │ ├── Person.cs │ │ │ │ ├── Product.cs │ │ │ │ └── Supplier.cs │ │ │ ├── ODataExtensions.cs │ │ │ ├── ODataOpenApiExample.csproj │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ │ └── launchSettings.json │ │ │ ├── SwaggerDefaultValues.cs │ │ │ ├── V1 │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── V2 │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── V3 │ │ │ │ ├── AcmeController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── PeopleController.cs │ │ │ │ ├── ProductsController.cs │ │ │ │ └── SuppliersController.cs │ │ │ └── appsettings.json │ │ └── SomeODataOpenApiExample │ │ │ ├── Book.cs │ │ │ ├── BooksController.cs │ │ │ ├── ConfigureSwaggerOptions.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── SomeODataOpenApiExample.csproj │ │ │ ├── SwaggerDefaultValues.cs │ │ │ └── appsettings.json │ └── WebApi │ │ ├── BasicExample │ │ ├── BasicExample.csproj │ │ ├── Controllers │ │ │ ├── HelloWorldController.cs │ │ │ ├── MultiVersionedController.cs │ │ │ ├── Values2Controller.cs │ │ │ └── ValuesController.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ └── appsettings.json │ │ ├── ByNamespaceExample │ │ ├── ByNamespaceExample.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── V1 │ │ │ ├── Controllers │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ │ ├── Agreement.cs │ │ │ │ └── Order.cs │ │ ├── V2 │ │ │ ├── Controllers │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ │ ├── Agreement.cs │ │ │ │ └── Order.cs │ │ ├── V3 │ │ │ ├── Controllers │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── Models │ │ │ │ ├── Agreement.cs │ │ │ │ └── Order.cs │ │ └── appsettings.json │ │ ├── ConventionsExample │ │ ├── Controllers │ │ │ ├── HelloWorldController.cs │ │ │ ├── Values2Controller.cs │ │ │ └── ValuesController.cs │ │ ├── ConventionsExample.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ └── appsettings.json │ │ ├── MinimalApiExample │ │ ├── MinimalApiExample.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ └── appsettings.json │ │ ├── MinimalOpenApiExample │ │ ├── ConfigureSwaggerOptions.cs │ │ ├── MinimalOpenApiExample.csproj │ │ ├── Models │ │ │ ├── V1 │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ ├── V2 │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ │ └── V3 │ │ │ │ ├── Order.cs │ │ │ │ └── Person.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── launchSettings.json │ │ ├── SwaggerDefaultValues.cs │ │ └── appsettings.json │ │ └── OpenApiExample │ │ ├── ConfigureSwaggerOptions.cs │ │ ├── OpenApiExample.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ └── launchSettings.json │ │ ├── SwaggerDefaultValues.cs │ │ ├── V1 │ │ ├── Controllers │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ └── Models │ │ │ ├── Order.cs │ │ │ └── Person.cs │ │ ├── V2 │ │ ├── Controllers │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ └── Models │ │ │ ├── Order.cs │ │ │ └── Person.cs │ │ ├── V3 │ │ ├── Controllers │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ └── Models │ │ │ ├── Order.cs │ │ │ └── Person.cs │ │ └── appsettings.json └── Directory.Build.props ├── logo.svg ├── nuget.config └── src ├── Abstractions ├── src │ └── Asp.Versioning.Abstractions │ │ ├── AdvertiseApiVersionsAttribute.cs │ │ ├── AmbiguousApiVersionException.cs │ │ ├── ApiVersion.cs │ │ ├── ApiVersionAttribute.cs │ │ ├── ApiVersionFormatProvider.cs │ │ ├── ApiVersionMapping.cs │ │ ├── ApiVersionMetadata.cs │ │ ├── ApiVersionModel.cs │ │ ├── ApiVersionModelDebugView.cs │ │ ├── ApiVersionModelExtensions.cs │ │ ├── ApiVersionNeutralAttribute.cs │ │ ├── ApiVersionParameterLocation.cs │ │ ├── ApiVersionParser.cs │ │ ├── ApiVersionProviderOptions.cs │ │ ├── ApiVersionsBaseAttribute.cs │ │ ├── Asp.Versioning.Abstractions.csproj │ │ ├── CollectionExtensions.cs │ │ ├── Conventions │ │ ├── ApiVersionConventionBuilderBase.cs │ │ ├── ApiVersionConventionBuilderExtensions.cs │ │ ├── IApiVersionConvention{T}.cs │ │ ├── IDeclareApiVersionConventionBuilder.cs │ │ └── IMapToApiVersionConventionBuilder.cs │ │ ├── Format.cs │ │ ├── FormatToken.cs │ │ ├── FormatTokenizer.cs │ │ ├── IApiVersionNeutral.cs │ │ ├── IApiVersionParameterDescriptionContext.cs │ │ ├── IApiVersionParameterSource.cs │ │ ├── IApiVersionParameterSourceExtensions.cs │ │ ├── IApiVersionProvider.cs │ │ ├── IApiVersioningPolicyBuilder.cs │ │ ├── IApiVersioningPolicyBuilderExtensions.cs │ │ ├── ILinkBuilder.cs │ │ ├── ILinkBuilderExtensions.cs │ │ ├── ISunsetPolicyBuilder.cs │ │ ├── ISunsetPolicyBuilderExtensions.cs │ │ ├── ISunsetPolicyManager.cs │ │ ├── ISunsetPolicyManagerExtensions.cs │ │ ├── LinkHeaderValue.cs │ │ ├── MapToApiVersionAttribute.cs │ │ ├── NamespaceParser.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── SR.Designer.cs │ │ ├── SR.resx │ │ ├── Str.cs │ │ ├── SunsetPolicy.cs │ │ ├── net#.0 │ │ └── ApiVersion.cs │ │ ├── netstandard1.0 │ │ ├── ApiVersion.cs │ │ ├── ApiVersionFormatProvider.cs │ │ ├── FormatWriter.cs │ │ └── IApiVersionParser.cs │ │ └── netstandard2.0 │ │ ├── AmbiguousApiVersionException.cs │ │ ├── ApiVersion.cs │ │ ├── ApiVersionFormatProvider.cs │ │ ├── FormatWriter.cs │ │ ├── IApiVersionParser.cs │ │ └── IApiVersionParserExtensions.cs └── test │ └── Asp.Versioning.Abstractions.Tests │ ├── AdvertiseApiVersionsAttributeTest.cs │ ├── ApiVersionAttributeTest.cs │ ├── ApiVersionFormatProviderTest.cs │ ├── ApiVersionMetadataTest.cs │ ├── ApiVersionModelExtensionsTest.cs │ ├── ApiVersionParserTest.cs │ ├── ApiVersionTest.cs │ ├── ApiVersionsBaseAttributeTest.cs │ ├── Asp.Versioning.Abstractions.Tests.csproj │ ├── AssumeCultureAttribute.cs │ ├── Conventions │ └── ApiVersionConventionBuilderBaseTest.cs │ ├── IApiVersionParameterSourceExtensionsTest.cs │ ├── IApiVersioningPolicyBuilderExtensionsTest.cs │ ├── ILinkBuilderExtensionsTest.cs │ ├── ISunsetPolicyBuilderExtensionsTest.cs │ ├── ISunsetPolicyManagerExtensionsTest.cs │ ├── LinkHeaderValueTest.cs │ ├── NamespaceParserTest.cs │ ├── SunsetPolicyTest.cs │ └── net#.0 │ └── ApiVersionTest.cs ├── AspNet ├── Acceptance │ └── Asp.Versioning.WebApi.Acceptance.Tests │ │ ├── Asp.Versioning.WebApi.Acceptance.Tests.csproj │ │ ├── FilteredControllerTypes.cs │ │ ├── Http │ │ ├── Basic │ │ │ ├── BasicFixture.cs │ │ │ ├── BasicTestCollection.cs │ │ │ ├── Controllers │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── OverlappingRouteTemplateController.cs │ │ │ │ ├── PingController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ └── ValuesController.cs │ │ │ ├── InteropFixture.cs │ │ │ ├── Models │ │ │ │ └── Order.cs │ │ │ ├── given a version-neutral ApiController │ │ │ │ └── when no version is specified.cs │ │ │ └── given a versioned ApiController │ │ │ │ ├── when a version is mapped only.cs │ │ │ │ ├── when error objects are enabled.cs │ │ │ │ ├── when two route templates overlap.cs │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ └── when using an action.cs │ │ ├── UsingConventions │ │ │ ├── Controllers │ │ │ │ ├── HelloWorld2Controller.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ └── ValuesController.cs │ │ │ ├── ConventionsFixture.cs │ │ │ ├── ConventionsTestCollection.cs │ │ │ ├── Models │ │ │ │ └── Order.cs │ │ │ └── given a versioned ApiController using conventions │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ └── when using an action.cs │ │ ├── UsingMediaType │ │ │ ├── Controllers │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ └── ValuesController.cs │ │ │ ├── MediaTypeFixture.cs │ │ │ ├── Models │ │ │ │ └── Message.cs │ │ │ └── given a versioned ApiController │ │ │ │ └── when using media type negotiation.cs │ │ └── UsingNamespace │ │ │ ├── AgreementsFixture.cs │ │ │ ├── AgreementsTestCollection.cs │ │ │ ├── Controllers │ │ │ ├── V1 │ │ │ │ ├── AgreementsController.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ └── OrdersController.cs │ │ │ ├── V2 │ │ │ │ ├── AgreementsController.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── V3 │ │ │ │ ├── AgreementsController.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ └── OrdersController.cs │ │ │ ├── HelloWorldFixture.cs │ │ │ ├── Models │ │ │ ├── Agreement.cs │ │ │ └── Order.cs │ │ │ ├── OrdersFixture.cs │ │ │ └── given a versioned ApiController per namespace │ │ │ ├── when using a query string.cs │ │ │ ├── when using a url segment and attribute-based routing.cs │ │ │ ├── when using a url segment and convention-based routing.cs │ │ │ └── when using an action.cs │ │ ├── HttpServerFixture.cs │ │ ├── OData │ │ ├── Advanced │ │ │ ├── AdvancedAcceptanceTest.cs │ │ │ ├── AdvancedFixture.cs │ │ │ ├── AdvancedTestCollection.cs │ │ │ ├── Controllers │ │ │ │ ├── Orders2Controller.cs │ │ │ │ ├── Orders3Controller.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── given a versioned ApiController mixed with OData controllers │ │ │ │ ├── when orders is v1.cs │ │ │ │ └── when orders is v3.cs │ │ │ └── given a versioned ODataController mixed with Web API controllers │ │ │ │ ├── when orders is v2.cs │ │ │ │ ├── when people is any version.cs │ │ │ │ ├── when people is v1.cs │ │ │ │ ├── when people is v2.cs │ │ │ │ └── when people is v3.cs │ │ ├── Basic │ │ │ ├── BasicAcceptanceTest.cs │ │ │ ├── BasicFixture.cs │ │ │ ├── BasicTestCollection.cs │ │ │ ├── Controllers │ │ │ │ ├── CustomersController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ ├── PeopleController.cs │ │ │ │ └── WeatherForecastsController.cs │ │ │ └── given a versioned ODataController │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a query string.cs │ │ │ │ ├── when using a url segment and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ ├── when using an action.cs │ │ │ │ └── when using built-in conventions.cs │ │ ├── Configuration │ │ │ ├── CustomerModelConfiguration.cs │ │ │ ├── OrderModelConfiguration.cs │ │ │ ├── PersonModelConfiguration.cs │ │ │ └── WeatherForecastModelConfiguration.cs │ │ ├── Models │ │ │ ├── Customer.cs │ │ │ ├── Order.cs │ │ │ ├── Person.cs │ │ │ └── WeatherForecast.cs │ │ ├── ODataAcceptanceTest.cs │ │ ├── ODataFixture.cs │ │ └── UsingConventions │ │ │ ├── Controllers │ │ │ ├── CustomersController.cs │ │ │ ├── OrdersController.cs │ │ │ ├── People2Controller.cs │ │ │ └── PeopleController.cs │ │ │ ├── ConventionsAcceptanceTest.cs │ │ │ ├── ConventionsFixture.cs │ │ │ ├── ConventionsTestCollection.cs │ │ │ └── given a versioned ODataController using conventions │ │ │ ├── when using a query string and split into two types.cs │ │ │ ├── when using a query string.cs │ │ │ ├── when using a url segment and split into two types.cs │ │ │ ├── when using a url segment.cs │ │ │ └── when using an action.cs │ │ └── TraceWriter.cs ├── OData │ ├── src │ │ ├── Asp.Versioning.WebApi.OData.ApiExplorer │ │ │ ├── ApiExplorer │ │ │ │ ├── AdHocEdmScope.cs │ │ │ │ ├── ODataApiExplorer.cs │ │ │ │ └── ODataApiExplorerOptions.cs │ │ │ ├── Asp.Versioning.WebApi.OData.ApiExplorer.csproj │ │ │ ├── Conventions │ │ │ │ ├── ImplicitModelBoundSettingsConvention.cs │ │ │ │ ├── ODataAttributeVisitor.cs │ │ │ │ ├── ODataParameterDescriptor.cs │ │ │ │ ├── ODataQueryOptionDescriptionContext.cs │ │ │ │ ├── ODataQueryOptionParameterDescriptor.cs │ │ │ │ ├── ODataQueryOptionsConventionBuilder.cs │ │ │ │ └── ODataValidationSettingsConvention.cs │ │ │ ├── DependencyResolverExtensions.cs │ │ │ ├── Description │ │ │ │ └── ODataModelBoundParameterDescriptor.cs │ │ │ ├── README.md │ │ │ ├── ReleaseNotes.txt │ │ │ ├── Routing │ │ │ │ ├── ODataRouteActionType.cs │ │ │ │ ├── ODataRouteBuilder.cs │ │ │ │ ├── ODataRouteBuilderContext.cs │ │ │ │ └── ODataRouteTemplateGenerationKind.cs │ │ │ ├── SR.Designer.cs │ │ │ ├── SR.resx │ │ │ ├── System.Web.Http │ │ │ │ ├── Description │ │ │ │ │ └── ApiDescriptionExtensions.cs │ │ │ │ ├── HttpConfigurationExtensions.cs │ │ │ │ └── HttpRouteCollectionExtensions.cs │ │ │ └── net45 │ │ │ │ └── TupleExtensions.cs │ │ └── Asp.Versioning.WebApi.OData │ │ │ ├── Asp.Versioning.WebApi.OData.csproj │ │ │ ├── Controllers │ │ │ └── VersionedMetadataController.cs │ │ │ ├── Microsoft.OData │ │ │ └── IContainerBuilderExtensions.cs │ │ │ ├── OData │ │ │ ├── EdmModelSelector.cs │ │ │ ├── IEdmModelSelector.cs │ │ │ └── VersionedODataModelBuilder.cs │ │ │ ├── README.md │ │ │ ├── ReleaseNotes.txt │ │ │ ├── Routing │ │ │ ├── ODataPathTemplateHandlerExtensions.cs │ │ │ ├── VersionedAttributeRoutingConvention.cs │ │ │ ├── VersionedMetadataRoutingConvention.cs │ │ │ └── VersionedODataRoutingConventions.cs │ │ │ ├── SR.Designer.cs │ │ │ ├── SR.resx │ │ │ ├── System.Net.Http │ │ │ └── HttpRequestMessageExtensions.cs │ │ │ └── System.Web.Http │ │ │ └── HttpConfigurationExtensions.cs │ └── test │ │ ├── Asp.Versioning.WebApi.OData.ApiExplorer.Tests │ │ ├── Asp.Versioning.WebApi.OData.ApiExplorer.Tests.csproj │ │ ├── Conventions │ │ │ ├── ODataQueryOptionsConventionBuilderTest.cs │ │ │ └── ODataValidationSettingsConventionTest.cs │ │ ├── Description │ │ │ ├── ControllerTypeCollection.cs │ │ │ ├── ODataApiExplorerTest.cs │ │ │ └── TestConfigurations.cs │ │ ├── Simulators │ │ │ ├── Configuration │ │ │ │ ├── OrderModelConfiguration.cs │ │ │ │ └── PersonModelConfiguration.cs │ │ │ ├── Models │ │ │ │ ├── Book.cs │ │ │ │ ├── Order.cs │ │ │ │ ├── Person.cs │ │ │ │ ├── Product.cs │ │ │ │ └── Supplier.cs │ │ │ ├── V1 │ │ │ │ ├── BooksController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── V2 │ │ │ │ ├── OrdersController.cs │ │ │ │ └── PeopleController.cs │ │ │ └── V3 │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── PeopleController.cs │ │ │ │ ├── ProductsController.cs │ │ │ │ └── SuppliersController.cs │ │ └── System.Web.Http │ │ │ ├── Description │ │ │ └── ApiDescriptionExtensionsTest.cs │ │ │ └── HttpConfigurationExtensionsTest.cs │ │ └── Asp.Versioning.WebApi.OData.Tests │ │ ├── Asp.Versioning.WebApi.OData.Tests.csproj │ │ ├── Controllers │ │ └── VersionedMetadataControllerTest.cs │ │ ├── OData │ │ ├── EdmModelSelectorTest.cs │ │ └── VersionedODataModelBuilderTest.cs │ │ ├── Routing │ │ ├── VersionedAttributeRoutingConventionTest.cs │ │ └── VersionedMetadataRoutingConventionTest.cs │ │ └── System.Web.Http │ │ └── HttpConfigurationExtensionsTest.cs └── WebApi │ ├── src │ ├── Asp.Versioning.WebApi.ApiExplorer │ │ ├── ApiExplorer │ │ │ ├── ApiExplorerOptions.cs │ │ │ └── VersionedApiExplorer.cs │ │ ├── Asp.Versioning.WebApi.ApiExplorer.csproj │ │ ├── CollectionExtensions.cs │ │ ├── Description │ │ │ ├── ApiDescriptionComparer.cs │ │ │ ├── ApiDescriptionGroup.cs │ │ │ ├── ApiDescriptionGroupCollection.cs │ │ │ ├── ApiVersionParameterDescriptionContext.cs │ │ │ ├── ApiVersionParameterDescriptor.cs │ │ │ └── VersionedApiDescription.cs │ │ ├── ForwardedTypes.cs │ │ ├── LocalSR.Designer.cs │ │ ├── LocalSR.resx │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── StringExtensions.cs │ │ ├── System.Web.Http │ │ │ ├── Controllers │ │ │ │ └── HttpActionDescriptorExtensions.cs │ │ │ ├── Description │ │ │ │ ├── ApiDescriptionExtensions.cs │ │ │ │ └── ApiParameterDescriptionExtensions.cs │ │ │ ├── HttpConfigurationExtensions.cs │ │ │ ├── MediaTypeFormatterAdapterFactory.cs │ │ │ └── MediaTypeFormatterExtensions.cs │ │ └── TypeExtensions.cs │ └── Asp.Versioning.WebApi │ │ ├── ApiVersionRequestProperties.cs │ │ ├── ApiVersioningOptions.cs │ │ ├── ApplyContentTypeVersionActionFilter.cs │ │ ├── Asp.Versioning.WebApi.csproj │ │ ├── ControllerNameAttribute.cs │ │ ├── Controllers │ │ ├── ActionSelectionResult.cs │ │ ├── ActionSelectorCacheItem.cs │ │ ├── AggregatedActionMapping.cs │ │ ├── ApiVersionActionSelector.cs │ │ ├── ApiVersionParameterBinding.cs │ │ ├── CandidateActionWithParams.cs │ │ ├── CandidateHttpActionDescriptor.cs │ │ ├── HttpControllerDescriptorGroup.cs │ │ └── StandardActionSelectionCache.cs │ │ ├── Conventions │ │ ├── ActionApiVersionConventionBuilderBase.cs │ │ ├── ApiVersionConventionBuilder.cs │ │ ├── ControllerApiVersionConventionBuilderBase.cs │ │ ├── DefaultControllerNameConvention.cs │ │ └── OriginalControllerNameConvention.cs │ │ ├── DefaultApiVersionReporter.cs │ │ ├── Dependencies │ │ └── DefaultContainer.cs │ │ ├── DependencyResolverExtensions.cs │ │ ├── Dispatcher │ │ ├── ApiVersionControllerSelector.cs │ │ ├── ControllerSelectionContext.cs │ │ ├── ControllerSelectionResult.cs │ │ ├── ControllerSelector.cs │ │ ├── ConventionRouteControllerSelector.cs │ │ ├── DirectRouteControllerSelector.cs │ │ ├── HttpControllerTypeCache.cs │ │ └── HttpResponseExceptionFactory.cs │ │ ├── DoNotReportApiVersions.cs │ │ ├── ErrorObjectFactory.cs │ │ ├── Formatting │ │ └── ProblemDetailsMediaTypeFormatter.cs │ │ ├── HeaderApiVersionReader.cs │ │ ├── IApiVersionSelectorExtensions.cs │ │ ├── IProblemDetailsFactory.cs │ │ ├── MediaTypeApiVersionReader.cs │ │ ├── MediaTypeApiVersionReaderBuilder.cs │ │ ├── NullTraceWriter.cs │ │ ├── ProblemDetails.cs │ │ ├── ProblemDetailsFactory.cs │ │ ├── QueryStringApiVersionReader.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── ReportApiVersionsAttribute.cs │ │ ├── Routing │ │ ├── ApiVersionRouteConstraint.cs │ │ ├── ApiVersionUrlHelper.cs │ │ ├── BoundRouteTemplateAdapter{T}.cs │ │ ├── CandidateAction.cs │ │ ├── IBoundRouteTemplate.cs │ │ ├── IParsedRoute.cs │ │ ├── IPathContentSegment.cs │ │ ├── IPathLiteralSubsegment.cs │ │ ├── IPathParameterSubsegment.cs │ │ ├── IPathSegment.cs │ │ ├── IPathSeparatorSegment.cs │ │ ├── IPathSubsegment.cs │ │ ├── ParsedRouteAdapter{T}.cs │ │ ├── PathContentSegmentAdapter{T}.cs │ │ ├── PathLiteralSubsegmentAdapter{T}.cs │ │ ├── PathParameterSubsegmentAdapter{T}.cs │ │ ├── PathSeparatorSegmentAdapter{T}.cs │ │ ├── RouteDataTokenKeys.cs │ │ ├── RouteParser.cs │ │ ├── RouteValueKeys.cs │ │ ├── UrlHelperExtensions.cs │ │ └── WithoutApiVersionUrlHelper.cs │ │ ├── SR.Designer.cs │ │ ├── SR.resx │ │ ├── SunsetPolicyManager.cs │ │ ├── System.Net.Http │ │ ├── HttpRequestMessageExtensions.cs │ │ └── HttpResponseMessageExtensions.cs │ │ ├── System.Web.Http │ │ ├── HttpActionDescriptorExtensions.cs │ │ ├── HttpConfigurationExtensions.cs │ │ ├── HttpControllerDescriptorExtensions.cs │ │ ├── HttpParameterBindingExtensions.cs │ │ ├── HttpRouteCollectionExtensions.cs │ │ ├── HttpRouteDataExtensions.cs │ │ └── HttpRouteExtensions.cs │ │ ├── TupleExtensions.cs │ │ └── UrlSegmentApiVersionReader.cs │ └── test │ ├── Asp.Versioning.WebApi.ApiExplorer.Tests │ ├── ApiExplorer │ │ ├── ControllerTypeCollection.cs │ │ ├── TestConfigurations.cs │ │ └── VersionedApiExplorerTest.cs │ ├── Asp.Versioning.WebApi.ApiExplorer.Tests.csproj │ ├── Description │ │ ├── ApiDescriptionGroupCollectionTest.cs │ │ ├── ApiVersionParameterDescriptionContextTest.cs │ │ ├── InternalTypeExtensions.cs │ │ └── VersionedApiDescriptionTest.cs │ ├── Models │ │ ├── ClassWithId.cs │ │ ├── GenericMutableObject{T}.cs │ │ ├── MutableObject.cs │ │ └── User.cs │ ├── Simulators │ │ ├── ApiExplorerValuesController.cs │ │ ├── AttributeApiExplorerValuesController.cs │ │ ├── AttributeValues1Controller.cs │ │ ├── AttributeValues2Controller.cs │ │ ├── AttributeValues3Controller.cs │ │ ├── DuplicatedIdController.cs │ │ ├── IgnoreApiValuesController.cs │ │ ├── Values2Controller.cs │ │ ├── Values3Controller.cs │ │ └── ValuesController.cs │ └── System.Web.Http.Description │ │ └── ApiDescriptionExtensionsTest.cs │ └── Asp.Versioning.WebApi.Tests │ ├── Asp.Versioning.WebApi.Tests.csproj │ ├── CompositeApiVersionReaderTest.cs │ ├── ConstantApiVersionSelectorTest.cs │ ├── Controllers │ ├── ApiVersionActionSelectorTest.cs │ ├── ApiVersionParameterBindingTest.cs │ └── HttpControllerDescriptorGroupTest.cs │ ├── Conventions │ ├── ActionApiVersionConventionBuilderTTest.cs │ ├── ActionApiVersionConventionBuilderTest.cs │ ├── ApiVersionConventionBuilderTest.cs │ ├── ControllerApiVersionConventionBuilderTTest.cs │ ├── ControllerApiVersionConventionBuilderTest.cs │ ├── DefaultControllerNameConventionTest.cs │ ├── GroupedControllerNameConventionTest.cs │ ├── OriginalControllerNameConventionTest.cs │ └── VersionByNamespaceConventionTest.cs │ ├── CurrentImplementationApiVersionSelectorTest.cs │ ├── DefaultApiVersionReporterTest.cs │ ├── DefaultApiVersionSelectorTest.cs │ ├── Dispatcher │ ├── ApiVersionControllerSelectorTest.AmbiguousControllers.cs │ └── ApiVersionControllerSelectorTest.cs │ ├── HeaderApiVersionReaderTest.cs │ ├── HttpContentExtensions.cs │ ├── LowestImplementedApiVersionSelectorTest.cs │ ├── MediaTypeApiVersionReaderBuilderTest.cs │ ├── MediaTypeApiVersionReaderTest.cs │ ├── QueryStringApiVersionReaderTest.cs │ ├── ReportApiVersionsAttributeTest.cs │ ├── Routing │ └── ApiVersionRouteConstraintTest.cs │ ├── Simulators │ ├── AdminController.cs │ ├── ApiVersionedRoute2Controller.cs │ ├── ApiVersionedRouteController.cs │ ├── AttributeRoutedTest2Controller.cs │ ├── AttributeRoutedTest4Controller.cs │ ├── AttributeRoutedTestController.cs │ ├── Conventions2Controller.cs │ ├── ConventionsController.cs │ ├── NeutralController.cs │ ├── OrdersController.cs │ ├── TestController.cs │ ├── TestVersion2Controller.cs │ └── TestVersionNeutralController.cs │ ├── System.Net.Http │ └── HttpRequestMessageExtensionsTest.cs │ ├── System.Web.Http │ ├── HttpActionDescriptorExtensionsTest.cs │ ├── HttpConfigurationExtensionsTest.cs │ └── HttpRouteCollectionExtensionsTest.cs │ └── UrlSegmentApiVersionReaderTest.cs ├── AspNetCore ├── Acceptance │ └── Asp.Versioning.Mvc.Acceptance.Tests │ │ ├── Asp.Versioning.Mvc.Acceptance.Tests.csproj │ │ ├── FilteredControllerTypes.cs │ │ ├── Http │ │ ├── MediaTypeFixture.cs │ │ ├── MinimalApiFixture.cs │ │ ├── MinimalApiTestCollection.cs │ │ ├── given a version-neutral minimal API │ │ │ ├── when any version is specified.cs │ │ │ └── when no version is specified.cs │ │ └── given a versioned minimal API │ │ │ ├── when using a media type.cs │ │ │ ├── when using a query string.cs │ │ │ ├── when using a url segment.cs │ │ │ └── when using an endpoint.cs │ │ ├── HttpServerFixture.cs │ │ ├── Mvc │ │ ├── UsingAttributes │ │ │ ├── BasicFixture.cs │ │ │ ├── BasicTestCollection.cs │ │ │ ├── Controllers │ │ │ │ ├── HelloWorld2Controller.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── OverlappingRouteTemplateController.cs │ │ │ │ ├── PingController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ ├── ValuesController.cs │ │ │ │ ├── WithViewsUsingAttributes │ │ │ │ │ └── HomeController.cs │ │ │ │ └── WithViewsUsingConventions │ │ │ │ │ └── HomeController.cs │ │ │ ├── Models │ │ │ │ └── Order.cs │ │ │ ├── OverlappingRouteTemplateFixture.cs │ │ │ ├── UIFixture.cs │ │ │ ├── given a version-neutral Controller │ │ │ │ └── when no version is specified.cs │ │ │ ├── given a version-neutral UI Controller │ │ │ │ ├── when accessing a view using attribute routing.cs │ │ │ │ └── when accessing a view using convention routing.cs │ │ │ └── given a versioned Controller │ │ │ │ ├── when a version is mapped only.cs │ │ │ │ ├── when two route templates overlap.cs │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ └── when using an action.cs │ │ ├── UsingConventions │ │ │ ├── Controllers │ │ │ │ ├── HelloWorld2Controller.cs │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ └── ValuesController.cs │ │ │ ├── ConventionsFixture.cs │ │ │ ├── ConventionsTestCollection.cs │ │ │ ├── Models │ │ │ │ └── Order.cs │ │ │ └── given a versioned Controller using conventions │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ └── when using an action.cs │ │ ├── UsingMediaType │ │ │ ├── Controllers │ │ │ │ ├── HelloWorldController.cs │ │ │ │ ├── Values2Controller.cs │ │ │ │ └── ValuesController.cs │ │ │ ├── MediaTypeFixture.cs │ │ │ ├── Models │ │ │ │ └── Message.cs │ │ │ └── given a versioned Controller │ │ │ │ └── when using media type negotiation.cs │ │ └── UsingNamespace │ │ │ ├── AgreementsFixture.cs │ │ │ ├── AgreementsTestCollection.cs │ │ │ ├── Controllers │ │ │ ├── V1 │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ ├── V2 │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ └── V3 │ │ │ │ ├── AgreementsController.cs │ │ │ │ └── OrdersController.cs │ │ │ ├── Models │ │ │ ├── Agreement.cs │ │ │ └── Order.cs │ │ │ ├── OrdersFixture.cs │ │ │ └── given a versioned Controller per namespace │ │ │ ├── when using a query string.cs │ │ │ ├── when using a url segment.cs │ │ │ └── when using an action.cs │ │ ├── OData │ │ ├── Advanced │ │ │ ├── AdvancedAcceptanceTest.cs │ │ │ ├── AdvancedFixture.cs │ │ │ ├── AdvancedTestCollection.cs │ │ │ ├── Controllers │ │ │ │ ├── Orders2Controller.cs │ │ │ │ ├── Orders3Controller.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ └── PeopleController.cs │ │ │ ├── given a versioned ControllerBase mixed with OData controllers │ │ │ │ ├── when orders is v1.cs │ │ │ │ └── when orders is v3.cs │ │ │ └── given a versioned ODataController mixed with base controllers │ │ │ │ ├── when orders is v2.cs │ │ │ │ ├── when people is any version.cs │ │ │ │ ├── when people is v1.cs │ │ │ │ ├── when people is v2.cs │ │ │ │ └── when people is v3.cs │ │ ├── Basic │ │ │ ├── BasicAcceptanceTest.cs │ │ │ ├── BasicFixture.cs │ │ │ ├── BasicTestCollection.cs │ │ │ ├── BatchAcceptanceTest.cs │ │ │ ├── Controllers │ │ │ │ ├── CustomersController.cs │ │ │ │ ├── OrdersController.cs │ │ │ │ ├── People2Controller.cs │ │ │ │ ├── PeopleController.cs │ │ │ │ └── WeatherForecastsController.cs │ │ │ ├── given a versioned ODataController │ │ │ │ ├── when using a query string and split into two types.cs │ │ │ │ ├── when using a query string.cs │ │ │ │ ├── when using a url segment and split into two types.cs │ │ │ │ ├── when using a url segment.cs │ │ │ │ ├── when using an action.cs │ │ │ │ └── when using built-in conventions.cs │ │ │ └── given versioned batch middleware │ │ │ │ ├── when using a query string.cs │ │ │ │ └── when using a url segment.cs │ │ ├── Configuration │ │ │ ├── CustomerModelConfiguration.cs │ │ │ ├── OrderModelConfiguration.cs │ │ │ ├── PersonModelConfiguration.cs │ │ │ └── WeatherForecastModelConfiguration.cs │ │ ├── Models │ │ │ ├── Customer.cs │ │ │ ├── Order.cs │ │ │ ├── Person.cs │ │ │ └── WeatherForecast.cs │ │ ├── ODataAcceptanceTest.cs │ │ ├── ODataFixture.cs │ │ └── UsingConventions │ │ │ ├── Controllers │ │ │ ├── CustomersController.cs │ │ │ ├── OrdersController.cs │ │ │ ├── People2Controller.cs │ │ │ └── PeopleController.cs │ │ │ ├── ConventionsAcceptanceTest.cs │ │ │ ├── ConventionsFixture.cs │ │ │ ├── ConventionsTestCollection.cs │ │ │ └── given a versioned ODataController using conventions │ │ │ ├── when using a query string and split into two types.cs │ │ │ ├── when using a query string.cs │ │ │ ├── when using a url segment and split into two types.cs │ │ │ ├── when using a url segment.cs │ │ │ └── when using an action.cs │ │ ├── TestApplicationPart.cs │ │ └── Views │ │ └── Home │ │ └── Index.cshtml ├── OData │ ├── src │ │ ├── Asp.Versioning.OData.ApiExplorer │ │ │ ├── ApiExplorer │ │ │ │ ├── ApiDescriptionExtensions.cs │ │ │ │ ├── ModelMetadataExtensions.cs │ │ │ │ ├── ODataApiDescriptionProvider.cs │ │ │ │ ├── ODataApiExplorerOptions.cs │ │ │ │ ├── ODataApiExplorerOptionsFactory.cs │ │ │ │ ├── ODataQueryOptionModelMetadata.cs │ │ │ │ ├── PartialODataDescriptionProvider.cs │ │ │ │ └── SubstitutedModelMetadata.cs │ │ │ ├── Asp.Versioning.OData.ApiExplorer.csproj │ │ │ ├── Conventions │ │ │ │ ├── ImplicitModelBoundSettingsConvention.cs │ │ │ │ ├── ODataAttributeVisitor.cs │ │ │ │ ├── ODataQueryOptionDescriptionContext.cs │ │ │ │ ├── ODataQueryOptionSettings.cs │ │ │ │ ├── ODataQueryOptionsConventionBuilder.cs │ │ │ │ └── ODataValidationSettingsConvention.cs │ │ │ ├── DependencyInjection │ │ │ │ └── IApiVersioningBuilderExtensions.cs │ │ │ ├── Format.cs │ │ │ ├── README.md │ │ │ └── ReleaseNotes.txt │ │ └── Asp.Versioning.OData │ │ │ ├── ApplicationModels │ │ │ └── ODataControllerSpecification.cs │ │ │ ├── Asp.Versioning.OData.csproj │ │ │ ├── Builder │ │ │ └── IApplicationBuilderExtensions.cs │ │ │ ├── Controllers │ │ │ └── VersionedMetadataController.cs │ │ │ ├── DependencyInjection │ │ │ ├── IApiVersioningBuilderExtensions.cs │ │ │ └── IServiceCollectionExtensions.cs │ │ │ ├── Format.cs │ │ │ ├── OData │ │ │ ├── Batch │ │ │ │ ├── ODataBatchPathMapping.cs │ │ │ │ ├── ODataBatchRequestServicesScope.cs │ │ │ │ ├── VersionedODataBatchHandler.cs │ │ │ │ ├── VersionedODataBatchMiddleware.cs │ │ │ │ └── VersionedUnbufferedODataBatchHandler.cs │ │ │ ├── IODataApiVersionCollectionProvider.cs │ │ │ ├── ModelConfigurationFeature.cs │ │ │ ├── ModelConfigurationFeatureProvider.cs │ │ │ ├── ODataApiVersionCollectionProvider.cs │ │ │ ├── ODataApiVersioningOptions.cs │ │ │ ├── ODataApiVersioningOptionsFactory.cs │ │ │ ├── ODataApplicationModelProvider.cs │ │ │ ├── ODataMultiModelApplicationModelProvider.cs │ │ │ ├── ODataOptionsPostSetup.cs │ │ │ ├── VersionedODataModelBuilder.cs │ │ │ ├── VersionedODataOptions.cs │ │ │ └── VersionedODataTemplateTranslator.cs │ │ │ ├── README.md │ │ │ ├── ReleaseNotes.txt │ │ │ ├── Routing │ │ │ ├── DefaultMetadataMatcherPolicy.cs │ │ │ ├── VersionedAttributeRoutingConvention.cs │ │ │ └── VersionedMetadataRoutingConvention.cs │ │ │ ├── SR.Designer.cs │ │ │ ├── SR.resx │ │ │ └── ServiceProviderExtensions.cs │ └── test │ │ ├── Asp.Versioning.OData.ApiExplorer.Tests │ │ ├── ApiExplorer │ │ │ └── ODataApiDescriptionProviderTest.cs │ │ ├── Asp.Versioning.OData.ApiExplorer.Tests.csproj │ │ ├── Conventions │ │ │ ├── ODataQueryOptionsConventionBuilderTest.cs │ │ │ └── ODataValidationSettingsConventionTest.cs │ │ └── Simulators │ │ │ ├── Configuration │ │ │ ├── AllConfigurations.cs │ │ │ ├── ApiVersions.cs │ │ │ ├── OrderModelConfiguration.cs │ │ │ ├── PersonModelConfiguration.cs │ │ │ ├── ProductConfiguration.cs │ │ │ └── SupplierConfiguration.cs │ │ │ ├── FunctionsController.cs │ │ │ ├── Models │ │ │ ├── Book.cs │ │ │ ├── Order.cs │ │ │ ├── Person.cs │ │ │ ├── Product.cs │ │ │ └── Supplier.cs │ │ │ ├── V1 │ │ │ ├── BooksController.cs │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ │ ├── V2 │ │ │ ├── OrdersController.cs │ │ │ └── PeopleController.cs │ │ │ └── V3 │ │ │ ├── OrdersController.cs │ │ │ ├── PeopleController.cs │ │ │ ├── ProductsController.cs │ │ │ └── SuppliersController.cs │ │ └── Asp.Versioning.OData.Tests │ │ ├── ApplicationModels │ │ └── ODataControllerSpecificationTest.cs │ │ ├── Asp.Versioning.OData.Tests.csproj │ │ ├── Controllers │ │ └── VersionedMetadataControllerTest.cs │ │ ├── OData │ │ ├── ModelConfigurationFeatureProviderTest.cs │ │ ├── ODataApiVersioningOptionsTest.cs │ │ ├── ODataOptionsPostSetupTest.cs │ │ ├── VersionedODataModelBuilderTest.cs │ │ └── VersionedODataOptionsTest.cs │ │ ├── Routing │ │ ├── DefaultMetadataMatcherPolicyTest.cs │ │ ├── VersionedAttributeRoutingConventionTest.cs │ │ └── VersionedMetadataRoutingConventionTest.cs │ │ ├── Simulators │ │ ├── Tests2Controller.cs │ │ ├── Tests3Controller.cs │ │ ├── TestsController.cs │ │ └── VersionNeutralController.cs │ │ └── TestApplicationPart.cs └── WebApi │ ├── src │ ├── Asp.Versioning.Http │ │ ├── ApiExplorer │ │ │ ├── ApiVersionDescription.cs │ │ │ ├── ApiVersionMetadataCollationCollection.cs │ │ │ ├── ApiVersionMetadataCollationContext.cs │ │ │ ├── DefaultEndpointInspector.cs │ │ │ ├── EndpointApiVersionMetadataCollationProvider.cs │ │ │ ├── IApiVersionDescriptionProvider.cs │ │ │ ├── IApiVersionDescriptionProviderFactory.cs │ │ │ ├── IApiVersionDescriptionProviderFactoryExtensions.cs │ │ │ ├── IApiVersionMetadataCollationProvider.cs │ │ │ └── IEndpointInspector.cs │ │ ├── ApiVersioningFeature.cs │ │ ├── Asp.Versioning.Http.csproj │ │ ├── Builder │ │ │ ├── ApiVersionSet.cs │ │ │ ├── ApiVersionSetBuilder.cs │ │ │ ├── ApiVersionSetBuilderFactory.cs │ │ │ ├── EndpointBuilderFinalizer.cs │ │ │ ├── IEndpointConventionBuilderExtensions.cs │ │ │ ├── IEndpointRouteBuilderExtensions.cs │ │ │ ├── IVersionedEndpointRouteBuilder.cs │ │ │ ├── VersionedEndpointRouteBuilder.cs │ │ │ └── VersionedEndpointRouteBuilderFactory.cs │ │ ├── DefaultApiVersionReporter.cs │ │ ├── DependencyInjection │ │ │ ├── ApiVersioningBuilder.cs │ │ │ └── IServiceCollectionExtensions.cs │ │ ├── ErrorObjectWriter.cs │ │ ├── Format.cs │ │ ├── HeaderApiVersionReader.cs │ │ ├── Http │ │ │ ├── HttpContextExtensions.cs │ │ │ ├── HttpRequestExtensions.cs │ │ │ └── HttpResponseExtensions.cs │ │ ├── IApiVersionSelector.cs │ │ ├── IApiVersionSelectorExtensions.cs │ │ ├── IApiVersioningBuilder.cs │ │ ├── IApiVersioningFeature.cs │ │ ├── ILoggerExtensions.cs │ │ ├── MediaTypeApiVersionReader.cs │ │ ├── MediaTypeApiVersionReaderBuilder.cs │ │ ├── QueryStringApiVersionReader.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── Rfc7231ProblemDetailsWriter.cs │ │ ├── Routing │ │ │ ├── AmbiguousApiVersionEndpoint.cs │ │ │ ├── ApiVersionLinkGenerator.cs │ │ │ ├── ApiVersionLinkGenerator{T}.cs │ │ │ ├── ApiVersionMatcherPolicy.cs │ │ │ ├── ApiVersionPolicyFeature.cs │ │ │ ├── ApiVersionPolicyJumpTable.cs │ │ │ ├── ApiVersionRouteConstraint.cs │ │ │ ├── ApiVersioningRouteOptionsSetup.cs │ │ │ ├── ClientErrorEndpointBuilder.cs │ │ │ ├── ContentTypeApiVersionDecorator.cs │ │ │ ├── EdgeBuilder.cs │ │ │ ├── EdgeKey.cs │ │ │ ├── EndpointProblem.cs │ │ │ ├── EndpointType.cs │ │ │ ├── MalformedApiVersionEndpoint.cs │ │ │ ├── NotAcceptableEndpoint.cs │ │ │ ├── ReportApiVersionsDecorator.cs │ │ │ ├── RouteDestination.cs │ │ │ ├── RoutePatternComparer.cs │ │ │ ├── RoutePatternExtensions.cs │ │ │ ├── UnspecifiedApiVersionEndpoint.cs │ │ │ ├── UnsupportedApiVersionEndpoint.cs │ │ │ └── UnsupportedMediaTypeEndpoint.cs │ │ ├── SR.Designer.cs │ │ ├── SR.resx │ │ ├── SunsetPolicyManager.cs │ │ ├── UrlSegmentApiVersionReader.cs │ │ └── ValidateApiVersioningOptions.cs │ ├── Asp.Versioning.Mvc.ApiExplorer │ │ ├── ApiDescriptionExtensions.cs │ │ ├── ApiExplorerOptions.cs │ │ ├── ApiExplorerOptionsFactory{T}.cs │ │ ├── ApiVersionDescriptionProviderFactory.cs │ │ ├── ApiVersionModelMetadata.cs │ │ ├── ApiVersionParameterDescriptionContext.cs │ │ ├── Asp.Versioning.Mvc.ApiExplorer.csproj │ │ ├── DefaultApiVersionDescriptionProvider.cs │ │ ├── DependencyInjection │ │ │ └── IApiVersioningBuilderExtensions.cs │ │ ├── FormatGroupNameCallback.cs │ │ ├── GroupedApiVersionDescriptionProvider.cs │ │ ├── IEndpointRouteBuilderExtensions.cs │ │ ├── Internal │ │ │ ├── ApiVersionDescriptionCollection.cs │ │ │ ├── ApiVersionDescriptionComparer.cs │ │ │ ├── DescriptionProvider.cs │ │ │ ├── GroupedApiVersion.cs │ │ │ ├── IGroupedApiVersionMetadata.cs │ │ │ └── IGroupedApiVersionMetadataFactory.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── SR.Designer.cs │ │ ├── SR.resx │ │ └── VersionedApiDescriptionProvider.cs │ └── Asp.Versioning.Mvc │ │ ├── Abstractions │ │ └── ActionDescriptorExtensions.cs │ │ ├── ApiExplorer │ │ ├── ActionApiVersionMetadataCollationProvider.cs │ │ └── MvcEndpointInspector.cs │ │ ├── ApiVersionCollator.cs │ │ ├── ApiVersionModelBinder.cs │ │ ├── ApiVersionModelBinderProvider.cs │ │ ├── ApiVersioningApplicationModelProvider.cs │ │ ├── ApiVersioningMvcOptionsSetup.cs │ │ ├── ApplicationModels │ │ ├── ApiBehaviorSpecification.cs │ │ ├── DefaultApiControllerFilter.cs │ │ ├── IApiControllerFilter.cs │ │ ├── IApiControllerSpecification.cs │ │ ├── ModelExtensions.cs │ │ └── NoControllerFilter.cs │ │ ├── ApplyContentTypeVersionActionFilter.cs │ │ ├── Asp.Versioning.Mvc.csproj │ │ ├── ControllerNameAttribute.cs │ │ ├── Conventions │ │ ├── ActionApiVersionConventionBuilderBase.cs │ │ ├── ApiVersionConventionBuilder.cs │ │ ├── ControllerApiVersionConventionBuilderBase.cs │ │ ├── DefaultControllerNameConvention.cs │ │ └── OriginalControllerNameConvention.cs │ │ ├── DependencyInjection │ │ └── IApiVersioningBuilderExtensions.cs │ │ ├── MvcApiVersioningOptions.cs │ │ ├── MvcApiVersioningOptionsFactory{T}.cs │ │ ├── MvcFormat.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── ReportApiVersionsAttribute.cs │ │ └── Routing │ │ ├── ApiVersionUrlHelper.cs │ │ ├── ApiVersionUrlHelperFactory.cs │ │ ├── IUrlHelperExtensions.cs │ │ └── WithoutApiVersionUrlHelper.cs │ └── test │ ├── Asp.Versioning.Http.Tests │ ├── Asp.Versioning.Http.Tests.csproj │ ├── Builder │ │ ├── ApiVersionSetTest.cs │ │ ├── IEndpointConventionBuilderExtensionsTest.cs │ │ └── IEndpointRouteBuilderExtensionsTest.cs │ ├── CompositeApiVersionReaderTest.cs │ ├── ConstantApiVersionSelectorTest.cs │ ├── CurrentImplementationApiVersionSelectorTest.cs │ ├── DefaultApiVersionReporterTest.cs │ ├── DefaultApiVersionSelectorTest.cs │ ├── DependencyInjection │ │ └── IServiceCollectionExtensionsTest.cs │ ├── ErrorObjectWriterTest.cs │ ├── HeaderApiVersionReaderTest.cs │ ├── Http │ │ ├── HttpContextExtensionsTest.cs │ │ └── HttpResponseExtensionsTest.cs │ ├── LowestImplementedApiVersionSelectorTest.cs │ ├── MediaTypeApiVersionBuilderTest.cs │ ├── MediaTypeApiVersionReaderTest.cs │ ├── QueryStringApiVersionReaderTest.cs │ ├── Routing │ │ ├── ApiVersionMatcherPolicyTest.cs │ │ ├── ApiVersionRouteConstraintTest.cs │ │ └── ApiVersioningRouteOptionsSetupTest.cs │ └── UrlSegmentApiVersionReaderTest.cs │ ├── Asp.Versioning.Mvc.ApiExplorer.Tests │ ├── ApiDescriptionExtensionsTest.cs │ ├── ApiVersionParameterDescriptionContextTest.cs │ ├── Asp.Versioning.Mvc.ApiExplorer.Tests.csproj │ ├── DefaultApiVersionDescriptionProviderTest.cs │ ├── GroupedApiVersionDescriptionProviderTest.cs │ ├── IApiDescriptionProviderExtensions.cs │ ├── TestActionDescriptorCollectionProvider.cs │ ├── TestEndpointDataSource.cs │ └── VersionedApiDescriptionProviderTest.cs │ └── Asp.Versioning.Mvc.Tests │ ├── ApiVersionCollatorTest.cs │ ├── ApiVersionModelBinderTest.cs │ ├── ApiVersioningApplicationModelProviderTest.cs │ ├── ApiVersioningMvcOptionsSetupTest.cs │ ├── ApplicationModels │ ├── ApiBehaviorSpecificationTest.cs │ └── DefaultApiControllerFilterTest.cs │ ├── Asp.Versioning.Mvc.Tests.csproj │ ├── Conventions │ ├── ActionApiVersionConventionBuilderTTest.cs │ ├── ActionApiVersionConventionBuilderTest.cs │ ├── ApiVersionConventionBuilderTest.cs │ ├── ControllerApiVersionConventionBuilderTTest.cs │ ├── ControllerApiVersionConventionBuilderTest.cs │ └── VersionByNamespaceConventionTest.cs │ ├── MvcApiVersioningOptionsFactoryTest.cs │ └── ReportApiVersionsAttributeTest.cs ├── Client ├── src │ └── Asp.Versioning.Http.Client │ │ ├── ApiInformation.cs │ │ ├── ApiNotification.cs │ │ ├── ApiNotificationContext.cs │ │ ├── ApiVersionEnumerator.cs │ │ ├── ApiVersionHandler.cs │ │ ├── ApiVersionHeaderEnumerable.cs │ │ ├── ApiVersionWriter.cs │ │ ├── Asp.Versioning.Http.Client.csproj │ │ ├── HeaderApiVersionWriter.cs │ │ ├── IApiNotification.cs │ │ ├── IApiVersionWriter.cs │ │ ├── MediaTypeApiVersionWriter.cs │ │ ├── QueryStringApiVersionWriter.cs │ │ ├── README.md │ │ ├── ReleaseNotes.txt │ │ ├── SR.Designer.cs │ │ ├── SR.resx │ │ ├── System.Net.Http │ │ ├── HttpClientExtensions.cs │ │ └── HttpResponseMessageExtensions.cs │ │ ├── UrlSegmentApiVersionWriter.cs │ │ └── net#.0 │ │ ├── ApiVersionHandlerLogger{T}.cs │ │ ├── DependencyInjection │ │ └── IHttpClientBuilderExtensions.cs │ │ └── ILoggerExtensions.cs └── test │ └── Asp.Versioning.Http.Client.Tests │ ├── ApiVersionEnumeratorTest.cs │ ├── ApiVersionHandlerTest.cs │ ├── ApiVersionWriterTest.cs │ ├── Asp.Versioning.Http.Client.Tests.csproj │ ├── HeaderApiVersionWriterTest.cs │ ├── MediaTypeApiVersionWriterTest.cs │ ├── QueryStringApiVersionWriterTest.cs │ ├── System.Net.Http │ ├── HttpClientExtensionsTest.cs │ └── HttpResponseMessageExtensionsTest.cs │ ├── TestServer.cs │ ├── UrlSegmentApiVersionWriterTest.cs │ └── net#.0 │ ├── ApiVersionHandlerLoggerTTest.cs │ └── DependencyInjection │ └── IHttpClientBuilderExtensionsTest.cs ├── Common ├── src │ ├── Common.ApiExplorer │ │ ├── ApiExplorerOptions.cs │ │ ├── Common.ApiExplorer.projitems │ │ ├── Common.ApiExplorer.shproj │ │ ├── ExpSR.Designer.cs │ │ ├── ExpSR.resx │ │ └── Resources.cs │ ├── Common.Backport │ │ ├── ArgumentException.cs │ │ ├── ArgumentNullException.cs │ │ ├── Array.cs │ │ ├── BitOperations.cs │ │ ├── CallerArgumentExpressionAttribute.cs │ │ ├── Common.Backport.msbuildproj │ │ ├── HashCode.cs │ │ ├── NullableAttributes.cs │ │ └── StringExtensions.cs │ ├── Common.Mvc │ │ ├── CollectionExtensions.cs │ │ ├── Common.Mvc.projitems │ │ ├── Common.Mvc.shproj │ │ ├── ControllerNameAttribute.cs │ │ ├── Conventions │ │ │ ├── ActionApiVersionConventionBuilder.cs │ │ │ ├── ActionApiVersionConventionBuilderBase.cs │ │ │ ├── ActionApiVersionConventionBuilderCollection.cs │ │ │ ├── ActionApiVersionConventionBuilderCollection{T}.cs │ │ │ ├── ActionApiVersionConventionBuilder{T}.cs │ │ │ ├── ActionConventionBuilderExtensions.cs │ │ │ ├── ActionMethodResolver.cs │ │ │ ├── ApiVersionConventionBuilder.cs │ │ │ ├── ControllerApiVersionConventionBuilder.cs │ │ │ ├── ControllerApiVersionConventionBuilder{T}.cs │ │ │ ├── ControllerConventionBuilderExtensions.cs │ │ │ ├── ControllerNameConvention.cs │ │ │ ├── ExpressionExtensions.cs │ │ │ ├── GroupedControllerNameConvention.cs │ │ │ ├── IActionConventionBuilder.cs │ │ │ ├── IActionConventionBuilder{T}.cs │ │ │ ├── IApiVersionConventionBuilder.cs │ │ │ ├── IControllerConvention.cs │ │ │ ├── IControllerConventionBuilder.cs │ │ │ ├── IControllerConventionBuilder{T}.cs │ │ │ ├── IControllerNameConvention.cs │ │ │ ├── OriginalControllerNameConvention.cs │ │ │ └── VersionByNamespaceConvention.cs │ │ ├── MvcSR.Designer.cs │ │ ├── MvcSR.resx │ │ └── ReportApiVersionsAttribute.cs │ ├── Common.OData.ApiExplorer │ │ ├── ApiExplorer │ │ │ ├── ODataApiExplorerOptions.cs │ │ │ └── ODataMetadataOptions.cs │ │ ├── CollectionExtensions.cs │ │ ├── Common.OData.ApiExplorer.projitems │ │ ├── Common.OData.ApiExplorer.shproj │ │ ├── Conventions │ │ │ ├── DefaultODataQueryOptionDescriptionProvider.cs │ │ │ ├── IODataActionQueryOptionsConventionBuilder.cs │ │ │ ├── IODataActionQueryOptionsConventionBuilder{T}.cs │ │ │ ├── IODataQueryOptionDescriptionProvider.cs │ │ │ ├── IODataQueryOptionsConvention.cs │ │ │ ├── IODataQueryOptionsConventionBuilder.cs │ │ │ ├── ImplicitModelBoundSettingsConvention.cs │ │ │ ├── ODataActionQueryOptionConventionLookup.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilder.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilderBase.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilderCollection.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilderCollection{T}.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilderExtensions.cs │ │ │ ├── ODataActionQueryOptionsConventionBuilder{T}.cs │ │ │ ├── ODataAttributeVisitor.cs │ │ │ ├── ODataControllerQueryOptionConvention.cs │ │ │ ├── ODataControllerQueryOptionsConventionBuilder.cs │ │ │ ├── ODataControllerQueryOptionsConventionBuilder{T}.cs │ │ │ ├── ODataQueryOptionDescriptionContext.cs │ │ │ ├── ODataQueryOptionSettings.cs │ │ │ ├── ODataQueryOptionsConventionBuilder.cs │ │ │ ├── ODataValidationSettingsConvention.cs │ │ │ └── ODataValidationSettingsExtensions.cs │ │ ├── Microsoft.OData.Edm │ │ │ └── EdmExtensions.cs │ │ ├── NullableExtensions.cs │ │ ├── OData │ │ │ ├── ClassProperty.cs │ │ │ ├── ClassSignature.cs │ │ │ ├── DefaultModelTypeBuilder.cs │ │ │ ├── EdmModelKey.cs │ │ │ ├── EdmTypeKey.cs │ │ │ ├── IModelTypeBuilder.cs │ │ │ ├── ODataValue{T}.cs │ │ │ ├── OriginalTypeAttribute.cs │ │ │ ├── PropertyDependency.cs │ │ │ ├── StructuredTypeResolver.cs │ │ │ ├── TypeExtensions.cs │ │ │ └── TypeSubstitutionContext.cs │ │ ├── ODataExpSR.Designer.cs │ │ └── ODataExpSR.resx │ ├── Common.OData │ │ ├── Common.OData.projitems │ │ ├── Common.OData.shproj │ │ ├── Microsoft.OData.Edm │ │ │ └── IEdmModelExtensions.cs │ │ ├── OData │ │ │ ├── AdHocAnnotation.cs │ │ │ ├── ApiVersionAnnotation.cs │ │ │ ├── DelegatingModelConfiguration.cs │ │ │ ├── IModelConfiguration.cs │ │ │ ├── ODataId.cs │ │ │ └── VersionedODataModelBuilder.cs │ │ └── TypeExtensions.cs │ ├── Common.ProblemDetails │ │ ├── Common.ProblemDetails.projitems │ │ ├── Common.ProblemDetails.shproj │ │ ├── ProblemDetailsDefaults.cs │ │ └── ProblemDetailsInfo.cs │ ├── Common.TypeInfo │ │ ├── Common.TypeInfo.projitems │ │ ├── Common.TypeInfo.shproj │ │ └── TypeExtensions.cs │ └── Common │ │ ├── ApiVersionReader.cs │ │ ├── ApiVersioningOptions.cs │ │ ├── ApiVersioningPolicyBuilder.cs │ │ ├── CollectionExtensions.cs │ │ ├── Common.projitems │ │ ├── Common.shproj │ │ ├── CommonSR.Designer.cs │ │ ├── CommonSR.resx │ │ ├── ConstantApiVersionSelector.cs │ │ ├── CurrentImplementationApiVersionSelector.cs │ │ ├── DefaultApiVersionReporter.cs │ │ ├── DefaultApiVersionSelector.cs │ │ ├── HeaderApiVersionReader.cs │ │ ├── IApiVersionReader.cs │ │ ├── IApiVersionSelector.cs │ │ ├── IReportApiVersions.cs │ │ ├── LowestImplementedApiVersionSelector.cs │ │ ├── MediaTypeApiVersionReader.cs │ │ ├── MediaTypeApiVersionReaderBuilder.cs │ │ ├── MediaTypeApiVersionReaderBuilderExtensions.cs │ │ ├── PolicyKey.cs │ │ ├── QueryStringApiVersionReader.cs │ │ ├── SunsetLinkBuilder.cs │ │ ├── SunsetPolicyBuilder.cs │ │ ├── SunsetPolicyManager.cs │ │ ├── UriExtensions.cs │ │ └── UrlSegmentApiVersionReader.cs └── test │ ├── Common.Acceptance.Tests │ ├── AcceptanceTest.cs │ ├── Common.Acceptance.Tests.projitems │ ├── Common.Acceptance.Tests.shproj │ ├── HttpContentExtensions.cs │ └── HttpServerFixture.cs │ ├── Common.Mvc.Tests │ ├── Common.Mvc.Tests.projitems │ ├── Common.Mvc.Tests.shproj │ ├── ControllerNameAttributeTest.cs │ └── Conventions │ │ ├── ActionApiVersionConventionBuilderExtensionsTTest.cs │ │ ├── ActionApiVersionConventionBuilderExtensionsTest.cs │ │ ├── ActionApiVersionConventionBuilderTTest.cs │ │ ├── ActionApiVersionConventionBuilderTest.cs │ │ ├── ActionConventionBuilderExtensionsTest.cs │ │ ├── ApiVersionConventionBuilderTest.cs │ │ ├── ControllerApiVersionConventionBuilderExtensionsTTest.cs │ │ ├── ControllerApiVersionConventionBuilderExtensionsTest.cs │ │ ├── ControllerApiVersionConventionBuilderTTest.cs │ │ ├── ControllerApiVersionConventionBuilderTest.cs │ │ ├── ControllerConventionBuilderExtensionsTest.cs │ │ ├── DefaultControllerNameConventionTest.cs │ │ ├── GroupedControllerNameConventionTest.cs │ │ ├── OriginalControllerNameConventionTest.cs │ │ └── VersionByNamespaceConventionTest.cs │ ├── Common.OData.ApiExplorer.Tests │ ├── Common.OData.ApiExplorer.Tests.projitems │ ├── Common.OData.ApiExplorer.Tests.shproj │ ├── Conventions │ │ ├── DefaultODataQueryOptionDescriptionProviderTest.cs │ │ ├── ODataActionQueryOptionsConventionBuilderExtensionsTest.cs │ │ ├── ODataActionQueryOptionsConventionBuilderTTest.cs │ │ ├── ODataActionQueryOptionsConventionBuilderTest.cs │ │ └── ODataQueryOptionsConventionBuilderTest.cs │ └── OData │ │ ├── Address.cs │ │ ├── AllowedRolesAttribute.cs │ │ ├── Company.cs │ │ ├── Contact.cs │ │ ├── DefaultModelTypeBuilderTest.cs │ │ ├── Employee.cs │ │ ├── Employer.cs │ │ └── Shipment.cs │ ├── Common.OData.Tests │ ├── Common.OData.Tests.projitems │ ├── Common.OData.Tests.shproj │ ├── OData │ │ └── ApiVersionAnnotationTest.cs │ ├── Test.cs │ ├── TestEntity.cs │ ├── TestModelConfiguration.cs │ └── TestNeutralEntity.cs │ └── Common.Tests │ ├── ApiVersioningPolicyBuilderTest.cs │ ├── Common.Tests.projitems │ ├── Common.Tests.shproj │ ├── MaxSelectVersionData.cs │ ├── MinSelectVersionData.cs │ ├── SelectVersionData.cs │ ├── SunsetPolicyBuilderTest.cs │ └── SunsetPolicyManagerTest.cs ├── Directory.Build.props └── Directory.Build.targets /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "sign": { 6 | "version": "0.9.1-beta.23530.1", 7 | "commands": [ 8 | "sign" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/dotnet/.devcontainer/base.Dockerfile 2 | 3 | # [Choice] .NET version: 7.0, 6.0, 5.0 4 | ARG VARIANT="8.0" 5 | FROM mcr.microsoft.com/vscode/devcontainers/dotnet -------------------------------------------------------------------------------- /.devcontainer/scripts/container-creation.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Install SDK and tool dependencies before container starts 6 | # Also run the full restore on the repo so that go-to definition 7 | # and other language features will be available in C# files 8 | dotnet restore 9 | 10 | # Add .NET Dev Certs to environment to facilitate debugging. 11 | # Do **NOT** do this in a public base image as all images inheriting 12 | # from the base image would inherit these dev certs as well. 13 | dotnet dev-certs https 14 | 15 | # The container creation script is executed in a new Bash instance 16 | # so we exit at the end to avoid the creation process lingering. 17 | exit -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # main branch 4 | - package-ecosystem: "nuget" 5 | directory: "/src" 6 | target-branch: "main" 7 | schedule: 8 | interval: "weekly" 9 | allow: 10 | - dependency-type: "all" 11 | assignees: 12 | - "commonsensesoftware" 13 | reviewers: 14 | - "commonsensesoftware" 15 | commit-message: 16 | prefix: "[main] " 17 | include: scope -------------------------------------------------------------------------------- /.github/signatures/cla.json: -------------------------------------------------------------------------------- 1 | { 2 | "signedContributors": [ 3 | { 4 | "name": "commonsensesoftware", 5 | "id": 11765008, 6 | "comment_id": 1100473258, 7 | "created_at": "2022-04-15T23:47:06Z", 8 | "repoId": 64226740, 9 | "pullRequestNo": 816 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": ".NET Core Attach", 6 | "type": "coreclr", 7 | "request": "attach", 8 | "processId": "${command:pickProcess}" 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /.vsconfig: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "components": [ 4 | "Microsoft.Net.Component.4.7.2.TargetingPack", 5 | "Microsoft.Net.Component.4.8.SDK", 6 | "Microsoft.Net.Component.4.8.TargetingPack", 7 | "Microsoft.VisualStudio.Workload.NetCoreTools", 8 | "Microsoft.VisualStudio.Workload.NetWeb" 9 | ] 10 | } -------------------------------------------------------------------------------- /build/acceptance.xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "methodDisplay": "classAndMethod", 3 | "methodDisplayOptions": "all" 4 | } -------------------------------------------------------------------------------- /build/assembly-info.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <_Parameter1>$(Company) 7 | 8 | 9 | <_Parameter1>false 10 | 11 | 12 | <_Parameter1>true 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /build/assets.msbuildproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard1.0 4 | false 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/code-analysis.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AllEnabledByDefault 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | .NET Foundation 6 | .NET Foundation and Contributors 7 | © $(Company). All rights reserved. 8 | en 9 | en-US 10 | 11 | 12 | 13 | latest 14 | enable 15 | true 16 | 17 | 18 | -------------------------------------------------------------------------------- /build/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/aspnet-api-versioning/39cfc87fd96972a8db19170d004ec89211e7161d/build/icon.png -------------------------------------------------------------------------------- /build/key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnet/aspnet-api-versioning/39cfc87fd96972a8db19170d004ec89211e7161d/build/key.snk -------------------------------------------------------------------------------- /build/resource.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/signing.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | true 7 | $(MSBuildThisFileDirectory)key.snk 8 | 0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb 9 | 10 | 11 | -------------------------------------------------------------------------------- /build/steps-ci.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: solution 3 | type: string 4 | default: '' 5 | - name: configuration 6 | type: string 7 | default: Release 8 | 9 | steps: 10 | - task: UseDotNet@2 11 | displayName: Install .NET SDK 12 | inputs: 13 | packageType: sdk 14 | version: 8.0.x # https://github.com/dotnet/core/blob/main/release-notes/releases-index.json 15 | 16 | - task: DotNetCoreCLI@2 17 | displayName: Build and Test 18 | inputs: 19 | command: test 20 | projects: ${{ parameters.solution }} 21 | arguments: --configuration ${{ parameters.configuration }} 22 | testRunTitle: Unit Tests 23 | publishTestResults: true -------------------------------------------------------------------------------- /build/stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "documentationRules": { 5 | "companyName": ".NET Foundation", 6 | "copyrightText": "Copyright (c) {companyName} and contributors. All rights reserved.", 7 | "documentInterfaces": true, 8 | "documentExposedElements": true, 9 | "documentInternalElements": false, 10 | "documentPrivateElements": false, 11 | "documentPrivateFields": false, 12 | "variables": {}, 13 | "xmlHeader": false 14 | }, 15 | "layoutRules": { 16 | "newlineAtEndOfFile": "omit" 17 | }, 18 | "orderingRules": { 19 | "blankLinesBetweenUsingGroups": "omit" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /build/test.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | disable 7 | false 8 | acceptance. 9 | 10 | 11 | 12 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /build/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "methodDisplay": "method", 3 | "methodDisplayOptions": "all" 4 | } -------------------------------------------------------------------------------- /examples/.editorconfig: -------------------------------------------------------------------------------- 1 | # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference 2 | 3 | [*.{cs,vb}] 4 | 5 | # ide code suppressions 6 | dotnet_diagnostic.IDE0059.severity = none 7 | dotnet_diagnostic.IDE0060.severity = none -------------------------------------------------------------------------------- /examples/AspNet/OData/AdvancedODataWebApiExample/AdvancedODataWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNet/OData/AdvancedODataWebApiExample/Controllers/Orders3Controller.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using ApiVersioning.Examples.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | [ApiVersion( 3.0 )] 8 | [ControllerName( "Orders" )] 9 | public class Orders3Controller : ApiController 10 | { 11 | // GET ~/api/orders?api-version=3.0 12 | public IHttpActionResult Get( ApiVersion version ) => 13 | Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{version}" } } ); 14 | 15 | // GET ~/api/orders/{id}?api-version=3.0 16 | public IHttpActionResult Get( int id, ApiVersion version ) => 17 | Ok( new Order() { Id = id, Customer = $"Customer v{version}" } ); 18 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/AdvancedODataWebApiExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/AdvancedODataWebApiExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/BasicODataWebApiExample/BasicODataWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNet/OData/BasicODataWebApiExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/BasicODataWebApiExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/ConventionsODataWebApiExample/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using ApiVersioning.Examples.Models; 4 | using Microsoft.AspNet.OData; 5 | using Microsoft.AspNet.OData.Query; 6 | using System.Web.Http; 7 | 8 | public class OrdersController : ODataController 9 | { 10 | // GET ~/api/v1/orders 11 | public IHttpActionResult Get( ODataQueryOptions options ) => 12 | Ok( new[] { new Order() { Id = 1, Customer = "Bill Mei" } } ); 13 | 14 | // GET ~/api/v1/orders/{key} 15 | public IHttpActionResult Get( int key, ODataQueryOptions options ) => 16 | Ok( new Order() { Id = key, Customer = "Bill Mei" } ); 17 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/ConventionsODataWebApiExample/ConventionsODataWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNet/OData/ConventionsODataWebApiExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/ConventionsODataWebApiExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/OpenApiODataWebApiExample/Configuration/AllConfigurations.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Configuration; 2 | 3 | using Asp.Versioning; 4 | using Asp.Versioning.OData; 5 | using Microsoft.AspNet.OData.Builder; 6 | 7 | /// 8 | /// Represents the model configuration for all configurations. 9 | /// 10 | public class AllConfigurations : IModelConfiguration 11 | { 12 | /// 13 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) 14 | { 15 | builder.Function( "GetSalesTaxRate" ).Returns().Parameter( "PostalCode" ); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/OpenApiODataWebApiExample/Configuration/ApiVersions.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Configuration; 2 | 3 | using Asp.Versioning; 4 | 5 | internal static class ApiVersions 6 | { 7 | internal static readonly ApiVersion V1 = new( 1, 0 ); 8 | internal static readonly ApiVersion V2 = new( 2, 0 ); 9 | internal static readonly ApiVersion V3 = new( 3, 0 ); 10 | } -------------------------------------------------------------------------------- /examples/AspNet/OData/OpenApiODataWebApiExample/OpenApiODataWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/AspNet/OData/SomeOpenApiODataWebApiExample/SomeOpenApiODataWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/AspNet/Startup.Newtonsoft.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples; 2 | 3 | using Newtonsoft.Json; 4 | 5 | public partial class Startup 6 | { 7 | // REF: https://github.com/advisories/GHSA-5crp-9r3c-p9vr 8 | static Startup() => JsonConvert.DefaultSettings = () => new() { MaxDepth = 128 }; 9 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/BasicWebApiExample/BasicWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/AspNet/WebApi/BasicWebApiExample/Controllers/Values2Controller.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using System.Net.Http; 5 | using System.Web.Http; 6 | 7 | [ApiVersion( 2.0 )] 8 | [Route( "api/values" )] 9 | public class Values2Controller : ApiController 10 | { 11 | // GET api/values?api-version=2.0 12 | public IHttpActionResult Get() => 13 | Ok( new 14 | { 15 | controller = GetType().Name, 16 | version = Request.GetRequestedApiVersion().ToString(), 17 | } ); 18 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/BasicWebApiExample/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using System.Web.Http; 5 | 6 | [ApiVersion( 1.0 )] 7 | [Route( "api/values" )] 8 | public class ValuesController : ApiController 9 | { 10 | // GET api/values?api-version=1.0 11 | public IHttpActionResult Get( ApiVersion apiVersion ) => 12 | Ok( new 13 | { 14 | controller = GetType().Name, 15 | version = apiVersion.ToString(), 16 | } ); 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/ByNamespaceWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V1/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Controllers; 2 | 3 | using ApiVersioning.Examples.V1.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | public class AgreementsController : ApiController 8 | { 9 | // GET ~/v1/agreements/{accountId} 10 | // GET ~/agreements/{accountId}?api-version=1.0 11 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V1/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Controllers; 2 | 3 | using ApiVersioning.Examples.V1.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | [RoutePrefix( "v{version:apiVersion}/orders" )] 8 | public class OrdersController : ApiController 9 | { 10 | // GET ~/v1/orders/{accountId} 11 | [Route( "{accountId}" )] 12 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 13 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 14 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V1/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V1/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V2/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Controllers; 2 | 3 | using ApiVersioning.Examples.V2.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | public class AgreementsController : ApiController 8 | { 9 | // GET ~/v2/agreements/{accountId} 10 | // GET ~/agreements/{accountId}?api-version=2.0 11 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V2/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Controllers; 2 | 3 | using ApiVersioning.Examples.V2.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | [RoutePrefix( "v{version:apiVersion}/[controller]" )] 8 | public class OrdersController : ApiController 9 | { 10 | // GET ~/v2/orders/{accountId} 11 | [Route( "{accountId}" )] 12 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 13 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 14 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V2/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V2/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V3/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Controllers; 2 | 3 | using ApiVersioning.Examples.V3.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | public class AgreementsController : ApiController 8 | { 9 | // GET ~/v3/agreements/{accountId} 10 | // GET ~/agreements/{accountId}?api-version=3.0 11 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V3/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Controllers; 2 | 3 | using ApiVersioning.Examples.V3.Models; 4 | using Asp.Versioning; 5 | using System.Web.Http; 6 | 7 | [RoutePrefix( "v{version:apiVersion}/[controller]" )] 8 | public class OrdersController : ApiController 9 | { 10 | // GET ~/v3/orders/{accountId} 11 | [Route( "{accountId}" )] 12 | public IHttpActionResult Get( string accountId, ApiVersion apiVersion ) => 13 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 14 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V3/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ByNamespaceWebApiExample/V3/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using System.Web.Http; 5 | 6 | [RoutePrefix( "api/v{version:apiVersion}/helloworld" )] 7 | public class HelloWorldController : ApiController 8 | { 9 | // GET api/v{version}/helloworld 10 | [Route] 11 | public IHttpActionResult Get( ApiVersion apiVersion ) => 12 | Ok( new { controller = GetType().Name, version = apiVersion.ToString() } ); 13 | 14 | // GET api/v{version}/helloworld/{id} 15 | [Route( "{id:int}" )] 16 | public IHttpActionResult Get( int id, ApiVersion apiVersion ) => 17 | Ok( new { controller = GetType().Name, id, version = apiVersion.ToString() } ); 18 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ConventionsWebApiExample/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using System.Web.Http; 5 | 6 | [RoutePrefix( "api/values" )] 7 | public class ValuesController : ApiController 8 | { 9 | // GET api/values?api-version=1.0 10 | [Route] 11 | public IHttpActionResult Get( ApiVersion apiVersion ) => 12 | Ok( new { controller = GetType().Name, version = apiVersion.ToString() } ); 13 | 14 | // GET api/values/{id}?api-version=1.0 15 | [Route( "{id:int}" )] 16 | public IHttpActionResult Get( int id, ApiVersion apiVersion ) => 17 | Ok( new { controller = GetType().Name, id, version = apiVersion.ToString() } ); 18 | } -------------------------------------------------------------------------------- /examples/AspNet/WebApi/ConventionsWebApiExample/ConventionsWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/AspNet/WebApi/OpenApiWebApiExample/OpenApiWebApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net48 5 | bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/AspNetCore/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | net8.0 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataAdvancedExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataAdvancedExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataAdvancedExample/ODataAdvancedExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataAdvancedExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataBasicExample/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using ApiVersioning.Examples.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Routing.Controllers; 8 | 9 | [ApiVersion( 1.0 )] 10 | public class OrdersController : ODataController 11 | { 12 | // GET ~/api/v1/orders 13 | [EnableQuery] 14 | public IActionResult Get( ODataQueryOptions options ) => 15 | Ok( new[] { new Order() { Id = 1, Customer = "Bill Mei" } } ); 16 | 17 | // GET ~/api/v1/orders/{key} 18 | [EnableQuery] 19 | public IActionResult Get( int key, ODataQueryOptions options ) => 20 | Ok( new Order() { Id = key, Customer = "Bill Mei" } ); 21 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataBasicExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataBasicExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataBasicExample/ODataBasicExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataBasicExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataConventionsExample/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using ApiVersioning.Examples.Models; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.AspNetCore.OData.Query; 6 | using Microsoft.AspNetCore.OData.Routing.Controllers; 7 | 8 | public class OrdersController : ODataController 9 | { 10 | // GET ~/v1/orders 11 | [EnableQuery] 12 | public IActionResult Get( ODataQueryOptions options ) => 13 | Ok( new[] { new Order() { Id = 1, Customer = "Bill Mei" } } ); 14 | 15 | // GET ~/api/v1/orders/{key} 16 | [EnableQuery] 17 | public IActionResult Get( int key, ODataQueryOptions options ) => 18 | Ok( new Order() { Id = key, Customer = "Bill Mei" } ); 19 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataConventionsExample/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 10 | 11 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 12 | 13 | [Required] 14 | public string Customer { get; set; } 15 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataConventionsExample/Models/Person.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Models; 2 | 3 | using System.ComponentModel.DataAnnotations; 4 | 5 | public class Person 6 | { 7 | public int Id { get; set; } 8 | 9 | [Required] 10 | [StringLength( 25 )] 11 | public string FirstName { get; set; } 12 | 13 | [Required] 14 | [StringLength( 25 )] 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataConventionsExample/ODataConventionsExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataConventionsExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataOpenApiExample/Configuration/AllConfigurations.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Configuration; 2 | 3 | using Asp.Versioning; 4 | using Asp.Versioning.OData; 5 | using Microsoft.OData.ModelBuilder; 6 | 7 | /// 8 | /// Represents the model configuration for all configurations. 9 | /// 10 | public class AllConfigurations : IModelConfiguration 11 | { 12 | /// 13 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) 14 | { 15 | builder.Function( "GetSalesTaxRate" ).Returns().Parameter( "PostalCode" ); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataOpenApiExample/Configuration/ApiVersions.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Configuration; 2 | 3 | using Asp.Versioning; 4 | 5 | internal static class ApiVersions 6 | { 7 | internal static readonly ApiVersion V1 = new( 1, 0 ); 8 | internal static readonly ApiVersion V2 = new( 2, 0 ); 9 | internal static readonly ApiVersion V3 = new( 3, 0 ); 10 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataOpenApiExample/ODataOpenApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/ODataOpenApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/SomeODataOpenApiExample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "SomeODataOpenApiExample": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "launchUrl": "swagger", 7 | "environmentVariables": { 8 | "ASPNETCORE_ENVIRONMENT": "Development" 9 | }, 10 | "applicationUrl": "https://localhost:64762;http://localhost:64763" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /examples/AspNetCore/OData/SomeODataOpenApiExample/SomeODataOpenApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNetCore/OData/SomeODataOpenApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/BasicExample/BasicExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/BasicExample/Controllers/MultiVersionedController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ApiVersion( 1.0 )] 7 | [ApiVersion( 2.0 )] 8 | [Route( "api/v{version:apiVersion}/[controller]" )] 9 | public class MultiVersionedController : ControllerBase 10 | { 11 | [HttpGet] 12 | public string Get( ApiVersion version ) => "Version " + version; 13 | 14 | [HttpGet, MapToApiVersion( 2.0 )] 15 | public string GetV2( ApiVersion version ) => "Version " + version; 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/BasicExample/Controllers/Values2Controller.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ApiVersion( 2.0 )] 7 | [Route( "api/values" )] 8 | public class Values2Controller : ControllerBase 9 | { 10 | // GET api/values?api-version=2.0 11 | [HttpGet] 12 | public string Get( ApiVersion apiVersion ) => $"Controller = {GetType().Name}\nVersion = {apiVersion}"; 13 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/BasicExample/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [ApiVersion( 1.0 )] 7 | [Route( "api/[controller]" )] 8 | public class ValuesController : ControllerBase 9 | { 10 | // GET api/values?api-version=1.0 11 | [HttpGet] 12 | public string Get( ApiVersion apiVersion ) => $"Controller = {GetType().Name}\nVersion = {apiVersion}"; 13 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/BasicExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/ByNamespaceExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V1/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Controllers; 2 | 3 | using ApiVersioning.Examples.V1.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class AgreementsController : ControllerBase 10 | { 11 | // GET ~/v1/agreements/{accountId} 12 | // GET ~/agreements/{accountId}?api-version=1.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V1/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Controllers; 2 | 3 | using ApiVersioning.Examples.V1.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class OrdersController : ControllerBase 10 | { 11 | // GET ~/v1/orders/{accountId} 12 | // GET ~/orders/{accountId}?api-version=1.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V1/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V1/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V1.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V2/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Controllers; 2 | 3 | using ApiVersioning.Examples.V2.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class AgreementsController : ControllerBase 10 | { 11 | // GET ~/v2/agreements/{accountId} 12 | // GET ~/agreements/{accountId}?api-version=2.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V2/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Controllers; 2 | 3 | using ApiVersioning.Examples.V2.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class OrdersController : ControllerBase 10 | { 11 | // GET ~/v2/orders/{accountId} 12 | // GET ~/orders/{accountId}?api-version=2.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V2/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V2/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V2.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V3/Controllers/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Controllers; 2 | 3 | using ApiVersioning.Examples.V3.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class AgreementsController : ControllerBase 10 | { 11 | // GET ~/v3/agreements/{accountId} 12 | // GET ~/agreements/{accountId}?api-version=3.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V3/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Controllers; 2 | 3 | using ApiVersioning.Examples.V3.Models; 4 | using Asp.Versioning; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "[controller]" )] 8 | [Route( "v{version:apiVersion}/[controller]" )] 9 | public class OrdersController : ControllerBase 10 | { 11 | // GET ~/v3/orders/{accountId} 12 | // GET ~/orders/{accountId}?api-version=3.0 13 | [HttpGet( "{accountId}" )] 14 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 15 | Ok( new Order( GetType().FullName, accountId, apiVersion.ToString() ) ); 16 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V3/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Models; 2 | 3 | public class Agreement 4 | { 5 | public Agreement( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/V3/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.V3.Models; 2 | 3 | public class Order 4 | { 5 | public Order( string controller, string accountId, string apiVersion ) 6 | { 7 | Controller = controller; 8 | AccountId = accountId; 9 | ApiVersion = apiVersion; 10 | } 11 | 12 | public string Controller { get; set; } 13 | 14 | public string AccountId { get; set; } 15 | 16 | public string ApiVersion { get; set; } 17 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ByNamespaceExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ConventionsExample/Controllers/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [Route( "api/v{version:apiVersion}/[controller]" )] 7 | public class HelloWorldController : ControllerBase 8 | { 9 | // GET api/v{version}/helloworld 10 | [HttpGet] 11 | public string Get( ApiVersion apiVersion ) => 12 | $"Controller = {GetType().Name}\nVersion = {apiVersion}"; 13 | 14 | // GET api/v{version}/helloworld/{id} 15 | [HttpGet( "{id:int}" )] 16 | public string Get( int id, ApiVersion apiVersion ) => 17 | $"Controller = {GetType().Name}\nId = {id}\nVersion = {apiVersion}"; 18 | } 19 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ConventionsExample/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | namespace ApiVersioning.Examples.Controllers; 2 | 3 | using Asp.Versioning; 4 | using Microsoft.AspNetCore.Mvc; 5 | 6 | [Route( "api/[controller]" )] 7 | public class ValuesController : ControllerBase 8 | { 9 | // GET api/values?api-version=1.0 10 | [HttpGet] 11 | public string Get( ApiVersion apiVersion ) => 12 | $"Controller = {GetType().Name}\nVersion = {apiVersion}"; 13 | 14 | // GET api/values/{id}?api-version=1.0 15 | [HttpGet( "{id:int}" )] 16 | public string Get( int id, ApiVersion apiVersion ) => 17 | $"Controller = {GetType().Name}\nId = {id}\nVersion = {apiVersion}"; 18 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ConventionsExample/ConventionsExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/ConventionsExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/MinimalApiExample/MinimalApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | enable 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/MinimalApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/MinimalOpenApiExample/MinimalOpenApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/MinimalOpenApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/OpenApiExample/OpenApiExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/AspNetCore/WebApi/OpenApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } -------------------------------------------------------------------------------- /examples/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ApiVersioning.Examples 6 | latest 7 | enable 8 | false 9 | false 10 | 11 | 12 | false 13 | 14 | 15 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/ApiVersionMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Represents the possible types of API version mappings. 7 | /// 8 | public enum ApiVersionMapping 9 | { 10 | /// 11 | /// Indicates no mapping. 12 | /// 13 | None, 14 | 15 | /// 16 | /// Indicates an explicit mapping. 17 | /// 18 | Explicit, 19 | 20 | /// 21 | /// Indicates an implicit mapping. 22 | /// 23 | Implicit, 24 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/ApiVersionModelDebugView.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using static System.String; 6 | 7 | internal sealed class ApiVersionModelDebugView( ApiVersionModel model ) 8 | { 9 | private const string Comma = ", "; 10 | 11 | public bool VersionNeutral => model.IsApiVersionNeutral; 12 | 13 | public string Declared => Join( Comma, model.DeclaredApiVersions ); 14 | 15 | public string Implemented => Join( Comma, model.ImplementedApiVersions ); 16 | 17 | public string Supported => Join( Comma, model.SupportedApiVersions ); 18 | 19 | public string Deprecated => Join( Comma, model.DeprecatedApiVersions ); 20 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/ApiVersionNeutralAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using static System.AttributeTargets; 6 | 7 | /// 8 | /// Represents the metadata to indicate an API is version-neutral. 9 | /// 10 | [AttributeUsage( Class | Method, AllowMultiple = false, Inherited = true )] 11 | public sealed class ApiVersionNeutralAttribute : Attribute, IApiVersionNeutral 12 | { 13 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/Conventions/IApiVersionConvention{T}.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | /// 6 | /// Defines the behavior of an API version convention. 7 | /// 8 | /// The type of item to apply the convention to. 9 | public interface IApiVersionConvention where T : notnull 10 | { 11 | /// 12 | /// Applies the API version convention. 13 | /// 14 | /// The descriptor to apply the convention to. 15 | void ApplyTo( T item ); 16 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/Conventions/IMapToApiVersionConventionBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | /// 6 | /// Defines the behavior of convention builder that builds mapped API versions. 7 | /// 8 | public interface IMapToApiVersionConventionBuilder : IDeclareApiVersionConventionBuilder 9 | { 10 | /// 11 | /// Maps the specified API version to the configured controller action. 12 | /// 13 | /// The API version to map to the action. 14 | void MapToApiVersion( ApiVersion apiVersion ); 15 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/Format.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | #if NET 6 | using System.Text; 7 | #endif 8 | 9 | internal static class Format 10 | { 11 | #if NETSTANDARD 12 | internal static readonly string ApiVersionBadStatus = SR.ApiVersionBadStatus; 13 | internal static readonly string ApiVersionBadGroupVersion = SR.ApiVersionBadGroupVersion; 14 | #else 15 | internal static readonly CompositeFormat ApiVersionBadStatus = CompositeFormat.Parse( SR.ApiVersionBadStatus ); 16 | internal static readonly CompositeFormat ApiVersionBadGroupVersion = CompositeFormat.Parse( SR.ApiVersionBadGroupVersion ); 17 | #endif 18 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/FormatToken.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable SA1121 5 | 6 | namespace Asp.Versioning; 7 | 8 | using System.Diagnostics; 9 | #if NETSTANDARD1_0 10 | using Text = System.String; 11 | #else 12 | using Text = System.ReadOnlySpan; 13 | #endif 14 | 15 | [DebuggerDisplay( $"{nameof( Format )} = {{{nameof( Format )},nq}}, {nameof( IsLiteral )} = {{{nameof( IsLiteral )},nq}}" )] 16 | internal readonly ref struct FormatToken 17 | { 18 | public readonly Text Format; 19 | public readonly bool IsLiteral; 20 | 21 | internal FormatToken( Text format, bool literal = false ) 22 | { 23 | Format = format; 24 | IsLiteral = literal; 25 | } 26 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/IApiVersionNeutral.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable CA1040 5 | 6 | namespace Asp.Versioning; 7 | 8 | /// 9 | /// Defines the behavior of an API that is version-neutral. 10 | /// 11 | public interface IApiVersionNeutral 12 | { 13 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/IApiVersionParameterDescriptionContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Defines the behavior of an object that contains API version parameter descriptions. 7 | /// 8 | public interface IApiVersionParameterDescriptionContext 9 | { 10 | /// 11 | /// Adds an API version parameter with the specified name, from the specified location. 12 | /// 13 | /// The name of the parameter. 14 | /// One of the values. 15 | void AddParameter( string name, ApiVersionParameterLocation location ); 16 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/IApiVersionParameterSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Defines the behavior of an object that is the source of API version parameters. 7 | /// 8 | public interface IApiVersionParameterSource 9 | { 10 | /// 11 | /// Provides API version parameter descriptions supported by the current source using the supplied context. 12 | /// 13 | /// The context used to add API version parameter descriptions. 14 | void AddParameters( IApiVersionParameterDescriptionContext context ); 15 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/IApiVersionProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Defines the behavior of an API version provider. 7 | /// 8 | public interface IApiVersionProvider 9 | { 10 | /// 11 | /// Gets the options associated with the provided API versions. 12 | /// 13 | ApiVersionProviderOptions Options { get; } 14 | 15 | /// 16 | /// Gets the defined API versions defined. 17 | /// 18 | /// A read-only list of API versions. 19 | IReadOnlyList Versions { get; } 20 | } -------------------------------------------------------------------------------- /src/Abstractions/src/Asp.Versioning.Abstractions/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Abstractions/test/Asp.Versioning.Abstractions.Tests/ILinkBuilderExtensionsTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | public class ILinkBuilderExtensionsTest 6 | { 7 | [Fact] 8 | public void link_should_build_url_from_string() 9 | { 10 | // arrange 11 | var builder = Mock.Of(); 12 | 13 | // act 14 | builder.Link( "http://tempuri.org" ); 15 | 16 | // assert 17 | Mock.Get( builder ).Verify( b => b.Link( new Uri( "http://tempuri.org" ) ) ); 18 | } 19 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/FilteredControllerTypes.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Web.Http.Dispatcher; 6 | 7 | internal sealed class FilteredControllerTypes : List, IHttpControllerTypeResolver 8 | { 9 | public ICollection GetControllerTypes( IAssembliesResolver assembliesResolver ) => this; 10 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/BasicTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.Basic; 4 | 5 | [CollectionDefinition( nameof( BasicTestCollection ) )] 6 | public sealed class BasicTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/Controllers/PingController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.Basic.Controllers; 4 | 5 | using System.Web.Http; 6 | using static System.Net.HttpStatusCode; 7 | 8 | [ApiVersionNeutral] 9 | [RoutePrefix( "api/ping" )] 10 | public class PingController : ApiController 11 | { 12 | [Route] 13 | public IHttpActionResult Get() => StatusCode( NoContent ); 14 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/Controllers/Values2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.Basic.Controllers; 4 | 5 | using System.Web.Http; 6 | 7 | [ApiVersion( "2.0" )] 8 | [Route( "api/values" )] 9 | public class Values2Controller : ApiController 10 | { 11 | public IHttpActionResult Get() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); 12 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.Basic.Controllers; 4 | 5 | using System.Web.Http; 6 | 7 | [ApiVersion( "1.0" )] 8 | [Route( "api/values" )] 9 | public class ValuesController : ApiController 10 | { 11 | public IHttpActionResult Get() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); 12 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/InteropFixture.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | // Ignore Spelling: Interop 4 | namespace Asp.Versioning.Http.Basic; 5 | 6 | using System.Web.Http; 7 | 8 | public class InteropFixture : BasicFixture 9 | { 10 | protected override void OnConfigure( HttpConfiguration configuration ) 11 | { 12 | configuration.ConvertProblemDetailsToErrorObject(); 13 | base.OnConfigure( configuration ); 14 | } 15 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/Basic/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.Basic.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingConventions/Controllers/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingConventions.Controllers; 4 | 5 | using System.Web.Http; 6 | 7 | [RoutePrefix( "api/v{version:apiVersion}/helloworld" )] 8 | public class HelloWorldController : ApiController 9 | { 10 | [Route] 11 | public IHttpActionResult Get() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); 12 | 13 | [Route( "{id:int}" )] 14 | public IHttpActionResult Get( int id ) => Ok( new { controller = GetType().Name, id, version = Request.GetRequestedApiVersion().ToString() } ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingConventions/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingConventions.Controllers; 4 | 5 | using System.Web.Http; 6 | 7 | [RoutePrefix( "api/values" )] 8 | public class ValuesController : ApiController 9 | { 10 | [Route] 11 | public IHttpActionResult Get() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); 12 | 13 | [Route( "{id:int}" )] 14 | public IHttpActionResult Get( int id ) => Ok( new { controller = GetType().Name, id, version = Request.GetRequestedApiVersion().ToString() } ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingConventions/ConventionsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingConventions; 4 | 5 | [CollectionDefinition( nameof( ConventionsTestCollection ) )] 6 | public class ConventionsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingConventions/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingConventions.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingMediaType/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingMediaType.Controllers; 4 | 5 | using System.Web.Http; 6 | 7 | [ApiVersion( "1.0" )] 8 | [RoutePrefix( "api/values" )] 9 | public class ValuesController : ApiController 10 | { 11 | [Route] 12 | public IHttpActionResult Get() => 13 | Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); 14 | 15 | [Route( "{id}" )] 16 | public IHttpActionResult Get( string id ) => 17 | Ok( new { controller = GetType().Name, Id = id, version = Request.GetRequestedApiVersion().ToString() } ); 18 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingMediaType/Models/Message.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingMediaType.Models; 4 | 5 | public class Message 6 | { 7 | public string Text { get; set; } 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/AgreementsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace; 4 | 5 | [CollectionDefinition( nameof( AgreementsTestCollection ) )] 6 | public class AgreementsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V1/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V1; 4 | 5 | using Asp.Versioning.Http.UsingNamespace.Models; 6 | using System.Web.Http; 7 | 8 | public class AgreementsController : ApiController 9 | { 10 | public IHttpActionResult Get( string accountId ) => Ok( new Agreement( GetType().FullName, accountId, Request.GetRequestedApiVersion().ToString() ) ); 11 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V1/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V1; 4 | 5 | using System.Web.Http; 6 | 7 | [Obsolete( "Deprecated" )] 8 | [Route( "api/HelloWorld" )] 9 | [Route( "api/{version:apiVersion}/HelloWorld" )] 10 | public class HelloWorldController : ApiController 11 | { 12 | public IHttpActionResult Get() => Ok( "V1" ); 13 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V2/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V2; 4 | 5 | using Asp.Versioning.Http.UsingNamespace.Models; 6 | using System.Web.Http; 7 | 8 | public class AgreementsController : ApiController 9 | { 10 | public IHttpActionResult Get( string accountId ) => Ok( new Agreement( GetType().FullName, accountId, Request.GetRequestedApiVersion().ToString() ) ); 11 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V2/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V2; 4 | 5 | using System.Web.Http; 6 | 7 | [Route( "api/HelloWorld" )] 8 | [Route( "api/{version:apiVersion}/HelloWorld" )] 9 | public class HelloWorldController : ApiController 10 | { 11 | public IHttpActionResult Get() => Ok( "V2" ); 12 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V3/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V3; 4 | 5 | using Asp.Versioning.Http.UsingNamespace.Models; 6 | using System.Web.Http; 7 | 8 | public class AgreementsController : ApiController 9 | { 10 | public IHttpActionResult Get( string accountId ) => Ok( new Agreement( GetType().FullName, accountId, Request.GetRequestedApiVersion().ToString() ) ); 11 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Controllers/V3/HelloWorldController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Controllers.V3; 4 | 5 | using System.Web.Http; 6 | 7 | [Route( "api/HelloWorld" )] 8 | [Route( "api/{version:apiVersion}/HelloWorld" )] 9 | public class HelloWorldController : ApiController 10 | { 11 | public IHttpActionResult Get() => Ok( "V3" ); 12 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Models; 4 | 5 | public class Agreement 6 | { 7 | public Agreement( string controller, string accountId, string apiVersion ) 8 | { 9 | Controller = controller; 10 | AccountId = accountId; 11 | ApiVersion = apiVersion; 12 | } 13 | 14 | public string Controller { get; set; } 15 | 16 | public string AccountId { get; set; } 17 | 18 | public string ApiVersion { get; set; } 19 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/Http/UsingNamespace/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http.UsingNamespace.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Advanced/AdvancedAcceptanceTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced; 4 | 5 | [Collection( "OData" + nameof( AdvancedTestCollection ) )] 6 | public abstract class AdvancedAcceptanceTest : ODataAcceptanceTest 7 | { 8 | protected AdvancedAcceptanceTest( AdvancedFixture fixture ) : base( fixture ) { } 9 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Advanced/AdvancedTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced; 4 | 5 | [CollectionDefinition( "OData" + nameof( AdvancedTestCollection ) )] 6 | public sealed class AdvancedTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Advanced/Controllers/Orders3Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced.Controllers; 4 | 5 | using Asp.Versioning.OData.Models; 6 | using System.Web.Http; 7 | 8 | [ApiVersion( "3.0" )] 9 | [ControllerName( "Orders" )] 10 | public class Orders3Controller : ApiController 11 | { 12 | public IHttpActionResult Get() => Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } ); 13 | 14 | public IHttpActionResult Get( int key ) => Ok( new Order() { Id = key, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Advanced/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced.Controllers; 4 | 5 | using Asp.Versioning.OData.Models; 6 | using System.Web.Http; 7 | 8 | public class OrdersController : ApiController 9 | { 10 | public IHttpActionResult Get() => Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } } ); 11 | 12 | public IHttpActionResult Get( int key ) => Ok( new Order() { Id = key, Customer = $"Customer v{Request.GetRequestedApiVersion()}" } ); 13 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Basic/BasicTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Basic; 4 | 5 | [CollectionDefinition( "OData" + nameof( BasicTestCollection ) )] 6 | public sealed class BasicTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Customer 8 | { 9 | public int Id { get; set; } 10 | 11 | [Required] 12 | [StringLength( 25 )] 13 | public string FirstName { get; set; } 14 | 15 | [Required] 16 | [StringLength( 25 )] 17 | public string LastName { get; set; } 18 | 19 | public string Email { get; set; } 20 | 21 | public string Phone { get; set; } 22 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Order 8 | { 9 | public int Id { get; set; } 10 | 11 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 12 | 13 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 14 | 15 | [Required] 16 | public string Customer { get; set; } 17 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Models/Person.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Person 8 | { 9 | public int Id { get; set; } 10 | 11 | [Required] 12 | [StringLength( 25 )] 13 | public string FirstName { get; set; } 14 | 15 | [Required] 16 | [StringLength( 25 )] 17 | public string LastName { get; set; } 18 | 19 | public string Email { get; set; } 20 | 21 | public string Phone { get; set; } 22 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/Models/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | public class WeatherForecast 6 | { 7 | public string Id { get; set; } 8 | 9 | public DateTime Date { get; set; } 10 | 11 | public double Temperature { get; set; } 12 | 13 | public string Summary { get; set; } 14 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/ODataFixture.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | using Asp.Versioning.Controllers; 6 | 7 | public abstract class ODataFixture : HttpServerFixture 8 | { 9 | protected ODataFixture() => FilteredControllerTypes.Add( typeof( VersionedMetadataController ) ); 10 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/UsingConventions/ConventionsAcceptanceTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.UsingConventions; 4 | 5 | [Collection( "OData" + nameof( ConventionsTestCollection ) )] 6 | public abstract class ConventionsAcceptanceTest : ODataAcceptanceTest 7 | { 8 | protected ConventionsAcceptanceTest( ConventionsFixture fixture ) : base( fixture ) { } 9 | } -------------------------------------------------------------------------------- /src/AspNet/Acceptance/Asp.Versioning.WebApi.Acceptance.Tests/OData/UsingConventions/ConventionsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.UsingConventions; 4 | 5 | [CollectionDefinition( "OData" + nameof( ConventionsTestCollection ) )] 6 | public class ConventionsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Conventions/ODataAttributeVisitor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | using Microsoft.AspNet.OData; 6 | using System.Web.Http.Controllers; 7 | 8 | internal sealed partial class ODataAttributeVisitor 9 | { 10 | private void VisitAction( HttpActionDescriptor action ) 11 | { 12 | var controller = action.ControllerDescriptor; 13 | var attributes = new List( controller.GetCustomAttributes( inherit: true ) ); 14 | 15 | attributes.AddRange( action.GetCustomAttributes( inherit: true ) ); 16 | VisitEnableQuery( attributes.ToArray() ); 17 | } 18 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Conventions/ODataQueryOptionsConventionBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | using System.Runtime.CompilerServices; 6 | using System.Web.Http.Description; 7 | 8 | /// 9 | /// Provides additional implementation specific to Microsoft ASP.NET Web API. 10 | /// 11 | public partial class ODataQueryOptionsConventionBuilder 12 | { 13 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 14 | private static Type GetController( ApiDescription apiDescription ) => 15 | apiDescription.ActionDescriptor.ControllerDescriptor.ControllerType; 16 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/DependencyResolverExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Asp.Versioning.OData; 6 | using System.Web.Http.Dependencies; 7 | 8 | internal static class DependencyResolverExtensions 9 | { 10 | internal static TService? GetService( this IDependencyResolver resolver ) => (TService) resolver.GetService( typeof( TService ) ); 11 | 12 | internal static IModelTypeBuilder GetModelTypeBuilder( this IDependencyResolver resolver ) => 13 | resolver.GetService() ?? new DefaultModelTypeBuilder(); 14 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Routing/ODataRouteActionType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal enum ODataRouteActionType 6 | { 7 | Unknown, 8 | EntitySet, 9 | BoundOperation, 10 | UnboundOperation, 11 | Singleton, 12 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/Routing/ODataRouteTemplateGenerationKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal enum ODataRouteTemplateGenerationKind 6 | { 7 | Client, 8 | Server, 9 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/System.Web.Http/HttpRouteCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System.Web.Http; 4 | 5 | using System.Web.Http.Routing; 6 | 7 | internal static class HttpRouteCollectionExtensions 8 | { 9 | internal static string? GetRouteName( this HttpRouteCollection routes, IHttpRoute route ) 10 | { 11 | foreach ( var item in routes.ToDictionary() ) 12 | { 13 | if ( Equals( item.Value, route ) ) 14 | { 15 | return item.Key; 16 | } 17 | } 18 | 19 | return default; 20 | } 21 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData.ApiExplorer/net45/TupleExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System; 4 | 5 | internal static class TupleExtensions 6 | { 7 | internal static void Deconstruct( this Tuple tuple, out T1 item1, out T2 item2 ) 8 | { 9 | item1 = tuple.Item1; 10 | item2 = tuple.Item2; 11 | } 12 | } -------------------------------------------------------------------------------- /src/AspNet/OData/src/Asp.Versioning.WebApi.OData/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Description/ControllerTypeCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Description; 4 | 5 | using System.Collections.ObjectModel; 6 | using System.Web.Http.Dispatcher; 7 | 8 | public class ControllerTypeCollection : Collection, IHttpControllerTypeResolver 9 | { 10 | public ControllerTypeCollection() { } 11 | 12 | public ControllerTypeCollection( params Type[] controllerTypes ) : base( controllerTypes.ToList() ) { } 13 | 14 | public ICollection GetControllerTypes( IAssembliesResolver assembliesResolver ) => this; 15 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Configuration/OrderModelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Configuration; 4 | 5 | using Asp.Versioning.OData; 6 | using Asp.Versioning.Simulators.Models; 7 | using Microsoft.AspNet.OData.Builder; 8 | 9 | public class OrderModelConfiguration : IModelConfiguration 10 | { 11 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) => 12 | builder.EntitySet( "Orders" ); 13 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Configuration/PersonModelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Configuration; 4 | 5 | using Asp.Versioning.OData; 6 | using Asp.Versioning.Simulators.Models; 7 | using Microsoft.AspNet.OData.Builder; 8 | 9 | public class PersonModelConfiguration : IModelConfiguration 10 | { 11 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) => 12 | builder.EntitySet( "People" ); 13 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Models/Book.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | using Microsoft.AspNet.OData.Query; 6 | 7 | [Filter( "author", "published" )] 8 | public class Book 9 | { 10 | public string Id { get; set; } 11 | 12 | public string Author { get; set; } 13 | 14 | public string Title { get; set; } 15 | 16 | public int Published { get; set; } 17 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Order 8 | { 9 | [Key] 10 | public int Id { get; set; } 11 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Models/Person.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Person 8 | { 9 | [Key] 10 | public int Id { get; set; } 11 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Models/Product.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | using System.ComponentModel.DataAnnotations.Schema; 6 | 7 | public class Product 8 | { 9 | public int Id { get; set; } 10 | 11 | public string Name { get; set; } 12 | 13 | public decimal Price { get; set; } 14 | 15 | public string Category { get; set; } 16 | 17 | [ForeignKey( nameof( Supplier ) )] 18 | public int? SupplierId { get; set; } 19 | 20 | public virtual Supplier Supplier { get; set; } 21 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/Models/Supplier.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | public class Supplier 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public ICollection Products { get; set; } 12 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/V1/OrdersController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.V1; 4 | 5 | using Asp.Versioning.OData; 6 | using Asp.Versioning.Simulators.Models; 7 | using Microsoft.AspNet.OData; 8 | using System.Web.Http; 9 | using System.Web.Http.Description; 10 | 11 | public class OrdersController : ODataController 12 | { 13 | [ResponseType( typeof( ODataValue ) )] 14 | public IHttpActionResult Get( int key ) => Ok( new Order() { Id = key } ); 15 | 16 | [ResponseType( typeof( ODataValue ) )] 17 | public IHttpActionResult Post( [FromBody] Order order ) 18 | { 19 | order.Id = 42; 20 | return Created( order ); 21 | } 22 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Simulators/V1/PeopleController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.V1; 4 | 5 | using Asp.Versioning.OData; 6 | using Asp.Versioning.Simulators.Models; 7 | using Microsoft.AspNet.OData; 8 | using Microsoft.AspNet.OData.Routing; 9 | using System.Web.Http; 10 | using System.Web.Http.Description; 11 | 12 | [ApiVersion( "0.9" )] 13 | [ApiVersion( "1.0" )] 14 | [ODataRoutePrefix( "People" )] 15 | public class PeopleController : ODataController 16 | { 17 | [HttpGet] 18 | [ODataRoute( "({id})" )] 19 | [ResponseType( typeof( ODataValue ) )] 20 | public IHttpActionResult Get( [FromODataUri] int id ) => Ok( new Person() { Id = id } ); 21 | } -------------------------------------------------------------------------------- /src/AspNet/OData/test/Asp.Versioning.WebApi.OData.Tests/Asp.Versioning.WebApi.OData.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net452;net472 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System.Collections.Generic; 4 | 5 | internal static class CollectionExtensions 6 | { 7 | internal static int IndexOf( this IEnumerable sequence, TItem item, IEqualityComparer comparer ) 8 | { 9 | var index = 0; 10 | 11 | foreach ( var element in sequence ) 12 | { 13 | if ( comparer.Equals( element, item ) ) 14 | { 15 | return index; 16 | } 17 | 18 | index++; 19 | } 20 | 21 | return -1; 22 | } 23 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/ForwardedTypes.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | using Asp.Versioning.Routing; 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: TypeForwardedTo( typeof( IBoundRouteTemplate ) )] 7 | [assembly: TypeForwardedTo( typeof( IParsedRoute ) )] 8 | [assembly: TypeForwardedTo( typeof( IPathContentSegment ) )] 9 | [assembly: TypeForwardedTo( typeof( IPathLiteralSubsegment ) )] 10 | [assembly: TypeForwardedTo( typeof( IPathParameterSubsegment ) )] 11 | [assembly: TypeForwardedTo( typeof( IPathSegment ) )] 12 | [assembly: TypeForwardedTo( typeof( IPathSeparatorSegment ) )] 13 | [assembly: TypeForwardedTo( typeof( IPathSubsegment ) )] 14 | [assembly: TypeForwardedTo( typeof( RouteParser ) )] -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/System.Web.Http/Description/ApiParameterDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System.Web.Http.Description; 4 | 5 | using Asp.Versioning; 6 | using System.Reflection; 7 | 8 | internal static class ApiParameterDescriptionExtensions 9 | { 10 | internal static IEnumerable GetBindableProperties( this ApiParameterDescription description ) => 11 | description.ParameterDescriptor.ParameterType.GetBindableProperties(); 12 | 13 | internal static bool CanConvertPropertiesFromString( this ApiParameterDescription description ) => 14 | description.GetBindableProperties().All( p => p.PropertyType.CanConvertFromString() ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi.ApiExplorer/System.Web.Http/MediaTypeFormatterExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System.Web.Http; 4 | 5 | using System.Net.Http.Formatting; 6 | 7 | internal static class MediaTypeFormatterExtensions 8 | { 9 | internal static MediaTypeFormatter Clone( this MediaTypeFormatter formatter ) => 10 | MediaTypeFormatterAdapterFactory.GetOrCreateCloneFunction( formatter )( formatter ); 11 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/ControllerNameAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Provides additional implementation specific to ASP.NET Web API. 7 | /// 8 | public sealed partial class ControllerNameAttribute : Attribute 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The name of the controller. 14 | public ControllerNameAttribute( string name ) => Name = name; 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Controllers/ActionSelectionResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Controllers; 4 | 5 | using System.Web.Http.Controllers; 6 | 7 | internal sealed class ActionSelectionResult 8 | { 9 | internal ActionSelectionResult( HttpActionDescriptor action ) => Action = action; 10 | 11 | internal ActionSelectionResult( Exception exception ) => Exception = exception; 12 | 13 | internal bool Succeeded => Exception == null; 14 | 15 | internal HttpActionDescriptor? Action { get; } 16 | 17 | internal Exception? Exception { get; } 18 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Controllers/StandardActionSelectionCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Controllers; 4 | 5 | using Asp.Versioning.Routing; 6 | using System.Web.Http.Controllers; 7 | 8 | internal sealed class StandardActionSelectionCache 9 | { 10 | internal ILookup? StandardActionNameMapping { get; set; } 11 | 12 | internal CandidateAction[]? StandardCandidateActions { get; set; } 13 | 14 | internal CandidateAction[][]? CacheListMethods { get; set; } 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Dispatcher/ControllerSelectionResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Dispatcher; 4 | 5 | using System.Web.Http.Controllers; 6 | 7 | internal sealed class ControllerSelectionResult 8 | { 9 | internal HttpControllerDescriptor? Controller { get; set; } 10 | 11 | internal string? ControllerName { get; set; } 12 | 13 | internal bool Succeeded => Controller != null; 14 | 15 | internal bool HasCandidates { get; set; } 16 | 17 | internal ApiVersion? RequestedVersion { get; set; } 18 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/DoNotReportApiVersions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using static Asp.Versioning.ApiVersionMapping; 6 | 7 | internal sealed class DoNotReportApiVersions : IReportApiVersions 8 | { 9 | public ApiVersionMapping Mapping => Explicit | Implicit; 10 | 11 | public void Report( HttpResponseMessage response, ApiVersionModel apiVersionModel ) { } 12 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/NullTraceWriter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Web.Http.Tracing; 6 | 7 | internal sealed class NullTraceWriter : ITraceWriter 8 | { 9 | private static NullTraceWriter? instance; 10 | 11 | private NullTraceWriter() { } 12 | 13 | internal static ITraceWriter Instance => instance ??= new(); 14 | 15 | public void Trace( HttpRequestMessage request, string category, TraceLevel level, Action traceAction ) { } 16 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IBoundRouteTemplate.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | using System.Web.Http.Routing; 6 | 7 | /// 8 | /// Defines the behavior of a bound route template. 9 | /// 10 | public interface IBoundRouteTemplate 11 | { 12 | /// 13 | /// Gets or sets the build template. 14 | /// 15 | /// The bound template. 16 | string BoundTemplate { get; set; } 17 | 18 | /// 19 | /// Gets or sets the template parameter values. 20 | /// 21 | /// The template route value dictionary. 22 | HttpRouteValueDictionary Values { get; set; } 23 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IPathLiteralSubsegment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | /// 6 | /// Defines the behavior of a a literal segment. 7 | /// 8 | public interface IPathLiteralSubsegment : IPathSubsegment 9 | { 10 | /// 11 | /// Gets the literal subsegment value. 12 | /// 13 | /// The literal subsegment value. 14 | string Literal { get; } 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IPathParameterSubsegment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | /// 6 | /// Defines the behavior of a parameter subsegment. 7 | /// 8 | public interface IPathParameterSubsegment : IPathSubsegment 9 | { 10 | /// 11 | /// Gets a value indicating whether the segment represents a "catch all". 12 | /// 13 | /// True if the segment represents a "catch all" (*); otherwise, false. 14 | bool IsCatchAll { get; } 15 | 16 | /// 17 | /// Gets the corresponding parameter name. 18 | /// 19 | /// The corresponding segment parameter name. 20 | string ParameterName { get; } 21 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IPathSegment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | /// 6 | /// Defines the behavior of a path segment. 7 | /// 8 | public interface IPathSegment 9 | { 10 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IPathSeparatorSegment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | /// 6 | /// Defines the behavior of a path separator. 7 | /// 8 | public interface IPathSeparatorSegment : IPathSegment 9 | { 10 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/IPathSubsegment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | /// 6 | /// Defines the behavior of a path subsegment. 7 | /// 8 | public interface IPathSubsegment 9 | { 10 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/PathSeparatorSegmentAdapter{T}.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal sealed class PathSeparatorSegmentAdapter : IPathSeparatorSegment where T : notnull 6 | { 7 | private readonly T adapted; 8 | 9 | public PathSeparatorSegmentAdapter( T adapted ) => this.adapted = adapted; 10 | 11 | public override string ToString() => adapted.ToString(); 12 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/RouteDataTokenKeys.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal static class RouteDataTokenKeys 6 | { 7 | internal const string Actions = "actions"; 8 | internal const string Controller = "controller"; 9 | internal const string Order = "order"; 10 | internal const string Precedence = "precedence"; 11 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/Routing/RouteValueKeys.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal static class RouteValueKeys 6 | { 7 | internal const string Action = "action"; 8 | internal const string Controller = "controller"; 9 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/SunsetPolicyManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | /// 6 | /// Provides additional content specific to ASP.NET Web API. 7 | /// 8 | public partial class SunsetPolicyManager 9 | { 10 | private readonly ApiVersioningOptions options; 11 | 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The associated API versioning options. 16 | public SunsetPolicyManager( ApiVersioningOptions options ) => this.options = options; 17 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/src/Asp.Versioning.WebApi/TupleExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | internal static class TupleExtensions 6 | { 7 | internal static void Deconstruct( this Tuple tuple, out T1 item1, out T2 item2 ) 8 | { 9 | item1 = tuple.Item1; 10 | item2 = tuple.Item2; 11 | } 12 | 13 | internal static void Deconstruct( this Tuple tuple, out T1 item1, out T2 item2, out T3 item3 ) 14 | { 15 | item1 = tuple.Item1; 16 | item2 = tuple.Item2; 17 | item3 = tuple.Item3; 18 | } 19 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/ApiExplorer/ControllerTypeCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | using System.Collections.ObjectModel; 6 | using System.Web.Http.Dispatcher; 7 | 8 | public class ControllerTypeCollection : Collection, IHttpControllerTypeResolver 9 | { 10 | public ControllerTypeCollection() { } 11 | 12 | public ControllerTypeCollection( params Type[] controllerTypes ) : base( controllerTypes.ToList() ) { } 13 | 14 | public ICollection GetControllerTypes( IAssembliesResolver assembliesResolver ) => this; 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Asp.Versioning.WebApi.ApiExplorer.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net452;net472 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Description/VersionedApiDescriptionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Description; 4 | 5 | using System.Web.Http.Description; 6 | 7 | public class VersionedApiDescriptionTest 8 | { 9 | [Fact] 10 | public void shadowed_ResponseDescription_property_should_set_internal_value() 11 | { 12 | // arrange 13 | var apiDescription = new VersionedApiDescription(); 14 | var responseDescription = new ResponseDescription() { Documentation = "Test" }; 15 | 16 | // act 17 | apiDescription.ResponseDescription = responseDescription; 18 | 19 | // assert 20 | apiDescription.ResponseDescription.Should().BeSameAs( responseDescription ); 21 | } 22 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/ClassWithId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Models; 4 | 5 | public class ClassWithId 6 | { 7 | public int Id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/GenericMutableObject{T}.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | //// Ignore Spelling: Foo 4 | 5 | namespace Asp.Versioning.Models; 6 | 7 | public class GenericMutableObject : List 8 | { 9 | public string Foo { get; set; } 10 | 11 | public string Bar { get; set; } 12 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/MutableObject.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | //// Ignore Spelling: Foo 4 | 5 | namespace Asp.Versioning.Models; 6 | 7 | public class MutableObject 8 | { 9 | public string Foo { get; set; } 10 | 11 | public string Bar { get; set; } 12 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Models/User.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Models; 4 | 5 | public class User 6 | { 7 | public string Name { get; set; } 8 | 9 | public int Age { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/ApiExplorerValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | using System.Web.Http.Description; 8 | 9 | public class ApiExplorerValuesController : ApiController 10 | { 11 | public void Get() { } 12 | 13 | [ApiExplorerSettings( IgnoreApi = true )] 14 | public void Post() { } 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/AttributeApiExplorerValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | public class AttributeApiExplorerValuesController : ApiController 9 | { 10 | [Route( "" )] 11 | [HttpGet] 12 | public void Action() { } 13 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/AttributeValues1Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using System.Web.Http; 6 | 7 | [ApiVersion( "1.0" )] 8 | [RoutePrefix( "Values" )] 9 | public class AttributeValues1Controller : ApiController 10 | { 11 | [Route] 12 | public IHttpActionResult Get() => Ok(); 13 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/DuplicatedIdController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0060 4 | 5 | namespace Asp.Versioning.Simulators; 6 | 7 | using Asp.Versioning.Models; 8 | using System.Web.Http; 9 | 10 | public class DuplicatedIdController : ApiController 11 | { 12 | public void Get( [FromUri] ClassWithId objectWithId ) { } 13 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/IgnoreApiValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | using System.Web.Http.Description; 8 | 9 | [ApiExplorerSettings( IgnoreApi = true )] 10 | public class IgnoreApiValuesController : ApiController 11 | { 12 | public void Get() { } 13 | 14 | public void Post() { } 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/Values2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0060 4 | 5 | namespace Asp.Versioning.Simulators; 6 | 7 | using Asp.Versioning.Models; 8 | using System.Web.Http; 9 | using System.Web.Http.Description; 10 | 11 | [ControllerName( "Values" )] 12 | public class Values2Controller : ApiController 13 | { 14 | public string Get() => "Test"; 15 | 16 | [ResponseType( typeof( string ) )] 17 | public IHttpActionResult GetV3() => Ok( "Test" ); 18 | 19 | public IHttpActionResult Get( int id ) => Ok(); 20 | 21 | public IHttpActionResult Post( ClassWithId resource ) 22 | { 23 | resource.Id = 1; 24 | return Created( "values/1", resource ); 25 | } 26 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/Values3Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0060 4 | 5 | namespace Asp.Versioning.Simulators; 6 | 7 | using Asp.Versioning.Models; 8 | using System.Web.Http; 9 | using static System.Net.HttpStatusCode; 10 | 11 | [ControllerName( "Values" )] 12 | public class Values3Controller : ApiController 13 | { 14 | public IHttpActionResult Get() => Ok(); 15 | 16 | public IHttpActionResult Get( int id ) => Ok(); 17 | 18 | public IHttpActionResult Post( ClassWithId resource ) 19 | { 20 | resource.Id = 2; 21 | return Created( "values/2", resource ); 22 | } 23 | 24 | public IHttpActionResult Delete( int id ) => StatusCode( NoContent ); 25 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.ApiExplorer.Tests/Simulators/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using System.Web.Http; 6 | 7 | public class ValuesController : ApiController 8 | { 9 | public IHttpActionResult Get() => Ok(); 10 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/ConstantApiVersionSelectorTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Net.Http; 6 | 7 | public class ConstantApiVersionSelectorTest 8 | { 9 | [Fact] 10 | public void select_version_should_return_constant_value() 11 | { 12 | // arrange 13 | var request = new HttpRequestMessage(); 14 | var version = new ApiVersion( new DateTime( 2016, 06, 22 ) ); 15 | var selector = new ConstantApiVersionSelector( version ); 16 | 17 | // act 18 | var selectedVersion = selector.SelectVersion( request, ApiVersionModel.Default ); 19 | 20 | // assert 21 | selectedVersion.Should().Be( version ); 22 | } 23 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Conventions/DefaultControllerNameConventionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | public partial class DefaultControllerNameConventionTest 6 | { 7 | [Theory] 8 | [InlineData( "Values" )] 9 | [InlineData( "ValuesController2" )] 10 | public void normalize_name_should_not_trim_suffix( string controllerName ) 11 | { 12 | // arrange 13 | var convention = new DefaultControllerNameConvention(); 14 | 15 | // act 16 | var name = convention.NormalizeName( controllerName ); 17 | 18 | // assert 19 | name.Should().Be( controllerName ); 20 | } 21 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Conventions/GroupedControllerNameConventionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | public partial class GroupedControllerNameConventionTest 6 | { 7 | [Fact] 8 | public void normalize_name_should_trim_suffix() 9 | { 10 | // arrange 11 | var convention = new GroupedControllerNameConvention(); 12 | 13 | // act 14 | var name = convention.NormalizeName( "ValuesController" ); 15 | 16 | // assert 17 | name.Should().Be( "Values" ); 18 | } 19 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Conventions/OriginalControllerNameConventionTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | public partial class OriginalControllerNameConventionTest 6 | { 7 | [Fact] 8 | public void normalize_name_should_trim_suffix() 9 | { 10 | // arrange 11 | var convention = new OriginalControllerNameConvention(); 12 | 13 | // act 14 | var name = convention.NormalizeName( "ValuesController" ); 15 | 16 | // assert 17 | name.Should().Be( "Values" ); 18 | } 19 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/AdminController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | //// Ignore Spelling: Admin 4 | 5 | namespace Asp.Versioning.Simulators; 6 | 7 | using System.Web.Http; 8 | 9 | [ApiVersionNeutral] 10 | public class AdminController : ApiController 11 | { 12 | [Route( "admin" )] 13 | public IHttpActionResult Get() => Ok(); 14 | 15 | [HttpPost] 16 | public IHttpActionResult SeedData() => Ok(); 17 | 18 | [HttpPost] 19 | public IHttpActionResult MarkAsTest() => Ok(); 20 | 21 | [HttpPost] 22 | [Route( "admin/inject" )] 23 | public IHttpActionResult Inject() => Ok(); 24 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/ApiVersionedRoute2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | [ApiVersion( "5.0" )] 9 | [ApiVersion( "4.0", Deprecated = true )] 10 | [Route( "api/v{version:apiVersion}/test" )] 11 | public sealed class ApiVersionedRoute2Controller : ApiController 12 | { 13 | [MapToApiVersion( "4.0" )] 14 | public Task GetV4() => Task.FromResult( "Test" ); 15 | 16 | public Task Get() => Task.FromResult( "Test" ); 17 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/ApiVersionedRouteController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | [ApiVersion( "1.0" )] 9 | [ApiVersion( "2.0" )] 10 | [ApiVersion( "3.0" )] 11 | [Route( "api/v{version:apiVersion}/test" )] 12 | public sealed class ApiVersionedRouteController : ApiController 13 | { 14 | public Task Get() => Task.FromResult( "Test" ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/AttributeRoutedTest2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | [AdvertiseApiVersions( "1.0" )] 9 | [ApiVersion( "2.0" )] 10 | [ApiVersion( "3.0" )] 11 | [RoutePrefix( "api/test" )] 12 | public sealed class AttributeRoutedTest2Controller : ApiController 13 | { 14 | [Route] 15 | public Task Get() => Task.FromResult( "Test" ); 16 | 17 | [Route] 18 | [MapToApiVersion( "3.0" )] 19 | public Task GetV3() => Task.FromResult( "Test" ); 20 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/AttributeRoutedTest4Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | [AdvertiseApiVersions( "1.0", "2.0", "3.0" )] 9 | [AdvertiseApiVersions( "3.0-Alpha", Deprecated = true )] 10 | [ApiVersion( "4.0" )] 11 | [RoutePrefix( "api/test" )] 12 | public sealed class AttributeRoutedTest4Controller : ApiController 13 | { 14 | [Route] 15 | public Task Get() => Task.FromResult( "Test" ); 16 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/AttributeRoutedTestController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0060 4 | 5 | namespace Asp.Versioning.Simulators; 6 | 7 | using System.Web.Http; 8 | 9 | [RoutePrefix( "api/test" )] 10 | public sealed class AttributeRoutedTestController : ApiController 11 | { 12 | [Route] 13 | public Task Get() => Task.FromResult( "Test" ); 14 | 15 | [Route( "{id}" )] 16 | public Task Get( string id ) => Task.FromResult( "Test" ); 17 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/Conventions2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using System.Web.Http; 6 | 7 | [ControllerName( "Conventions" )] 8 | [RoutePrefix( "api/conventions" )] 9 | public sealed class Conventions2Controller : ApiController 10 | { 11 | [Route] 12 | public Task Get() => Task.FromResult( Ok( $"Test ({Request.GetRequestedApiVersion()})" ) ); 13 | 14 | [Route( "{id:int}" )] 15 | public Task Get( int id ) => Task.FromResult( Ok( $"Test {id} ({Request.GetRequestedApiVersion()})" ) ); 16 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/ConventionsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | public sealed class ConventionsController : ApiController 9 | { 10 | public string Get() => "Test (1.0)"; 11 | 12 | public string Get( int id ) => $"Test {id} (1.0)"; 13 | 14 | public string GetV2() => "Test (2.0)"; 15 | 16 | public string GetV2( int id ) => $"Test {id} (2.0)"; 17 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/NeutralController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Net.Http; 7 | using System.Web.Http.Controllers; 8 | 9 | [ApiVersionNeutral] 10 | public sealed class NeutralController : IHttpController 11 | { 12 | public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); 13 | 14 | public Task Get() => Task.FromResult( "Test" ); 15 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/OrdersController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Web.Http; 7 | 8 | [ApiVersion( "2015-11-15" )] 9 | [ApiVersion( "2016-06-06" )] 10 | public class OrdersController : ApiController 11 | { 12 | [MapToApiVersion( "2015-11-15" )] 13 | public Task Get_2015_11_15() => Task.FromResult( Ok( "Version 2015-11-15" ) ); 14 | 15 | [Route( "orders" )] 16 | [MapToApiVersion( "2016-06-06" )] 17 | public Task Get_2016_06_06() => Task.FromResult( Ok( "Version 2016-06-06" ) ); 18 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/TestController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Net.Http; 7 | using System.Web.Http.Controllers; 8 | 9 | public sealed class TestController : IHttpController 10 | { 11 | public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); 12 | 13 | public Task Get() => Task.FromResult( "Test" ); 14 | } -------------------------------------------------------------------------------- /src/AspNet/WebApi/test/Asp.Versioning.WebApi.Tests/Simulators/TestVersionNeutralController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | 4 | namespace Asp.Versioning.Simulators; 5 | 6 | using System.Net.Http; 7 | using System.Web.Http; 8 | using System.Web.Http.Controllers; 9 | 10 | [ApiVersionNeutral] 11 | [RoutePrefix( "api/neutral" )] 12 | public sealed class TestVersionNeutralController : IHttpController 13 | { 14 | public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); 15 | 16 | [Route] 17 | public Task Get() => Task.FromResult( "Test" ); 18 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Http/MediaTypeFixture.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http; 4 | 5 | public class MediaTypeFixture : MinimalApiFixture 6 | { 7 | protected override void OnAddApiVersioning( ApiVersioningOptions options ) => 8 | options.ApiVersionReader = new MediaTypeApiVersionReader(); 9 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Http/MinimalApiTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http; 4 | 5 | [CollectionDefinition( nameof( MinimalApiTestCollection ) )] 6 | public class MinimalApiTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/BasicTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes; 4 | 5 | [CollectionDefinition( nameof( BasicTestCollection ) )] 6 | public sealed class BasicTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/Controllers/PingController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes.Controllers; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [ApiController] 8 | [ApiVersionNeutral] 9 | [Route( "api/[controller]" )] 10 | public class PingController : ControllerBase 11 | { 12 | [HttpGet] 13 | public IActionResult Get() => NoContent(); 14 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/Controllers/WithViewsUsingAttributes/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes.Controllers.WithViewsUsingAttributes; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | [Route( "" )] 8 | [Route( "[controller]" )] 9 | public class HomeController : Controller 10 | { 11 | [HttpGet( "" )] 12 | [HttpGet( nameof( Index ) )] 13 | public IActionResult Index() => View(); 14 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/Controllers/WithViewsUsingConventions/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes.Controllers.WithViewsUsingConventions; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | public class HomeController : Controller 8 | { 9 | public IActionResult Index() => View(); 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingAttributes/OverlappingRouteTemplateFixture.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingAttributes; 4 | 5 | using Asp.Versioning.Mvc.UsingAttributes.Controllers; 6 | 7 | public class OverlappingRouteTemplateFixture : HttpServerFixture 8 | { 9 | public OverlappingRouteTemplateFixture() => FilteredControllerTypes.Add( typeof( OverlappingRouteTemplateController ) ); 10 | 11 | protected override void OnAddApiVersioning( ApiVersioningOptions options ) => options.ReportApiVersions = true; 12 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingConventions/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingConventions.Controllers; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | [ApiController] 9 | [Route( "api/[controller]" )] 10 | public class ValuesController : ControllerBase 11 | { 12 | [HttpGet] 13 | public IActionResult Get() => Ok( new { Controller = nameof( ValuesController ), Version = HttpContext.GetRequestedApiVersion().ToString() } ); 14 | 15 | [HttpGet( "{id:int}" )] 16 | public IActionResult Get( int id ) => Ok( new { Controller = nameof( ValuesController ), Id = id, Version = HttpContext.GetRequestedApiVersion().ToString() } ); 17 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingConventions/ConventionsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingConventions; 4 | 5 | [CollectionDefinition( nameof( ConventionsTestCollection ) )] 6 | public class ConventionsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingConventions/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingConventions.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingMediaType/Models/Message.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingMediaType.Models; 4 | 5 | public class Message 6 | { 7 | public string Text { get; set; } 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/AgreementsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace; 4 | 5 | [CollectionDefinition( nameof( AgreementsTestCollection ) )] 6 | public class AgreementsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/Controllers/V1/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace.Controllers.V1; 4 | 5 | using Asp.Versioning.Mvc.UsingNamespace.Models; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | public class AgreementsController : ControllerBase 9 | { 10 | [HttpGet] 11 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/Controllers/V2/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace.Controllers.V2; 4 | 5 | using Asp.Versioning.Mvc.UsingNamespace.Models; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | public class AgreementsController : ControllerBase 9 | { 10 | [HttpGet] 11 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/Controllers/V3/AgreementsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace.Controllers.V3; 4 | 5 | using Asp.Versioning.Mvc.UsingNamespace.Models; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | public class AgreementsController : ControllerBase 9 | { 10 | [HttpGet] 11 | public IActionResult Get( string accountId, ApiVersion apiVersion ) => 12 | Ok( new Agreement( GetType().FullName, accountId, apiVersion.ToString() ) ); 13 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/Models/Agreement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace.Models; 4 | 5 | public class Agreement 6 | { 7 | public Agreement( string controller, string accountId, string apiVersion ) 8 | { 9 | Controller = controller; 10 | AccountId = accountId; 11 | ApiVersion = apiVersion; 12 | } 13 | 14 | public string Controller { get; set; } 15 | 16 | public string AccountId { get; set; } 17 | 18 | public string ApiVersion { get; set; } 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Mvc/UsingNamespace/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Mvc.UsingNamespace.Models; 4 | 5 | public class Order 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Customer { get; set; } 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Advanced/AdvancedAcceptanceTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced; 4 | 5 | [Collection( "OData" + nameof( AdvancedTestCollection ) )] 6 | public abstract class AdvancedAcceptanceTest : ODataAcceptanceTest 7 | { 8 | protected AdvancedAcceptanceTest( ODataFixture fixture ) : base( fixture ) { } 9 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Advanced/AdvancedTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced; 4 | 5 | [CollectionDefinition( "OData" + nameof( AdvancedTestCollection ) )] 6 | public sealed class AdvancedTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Advanced/Controllers/OrdersController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Advanced.Controllers; 4 | 5 | using Asp.Versioning.OData.Models; 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | [ApiController] 9 | [Route( "api/orders" )] 10 | public class OrdersController : ControllerBase 11 | { 12 | [HttpGet] 13 | public IActionResult Get( ApiVersion apiVersion ) => 14 | Ok( new[] { new Order() { Id = 1, Customer = $"Customer v{apiVersion}" } } ); 15 | 16 | [HttpGet( "{key}" )] 17 | public IActionResult Get( int key, ApiVersion apiVersion ) => 18 | Ok( new Order() { Id = key, Customer = $"Customer v{apiVersion}" } ); 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/BasicTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Basic; 4 | 5 | [CollectionDefinition( "OData" + nameof( BasicTestCollection ) )] 6 | public sealed class BasicTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Customer 8 | { 9 | public int Id { get; set; } 10 | 11 | [Required] 12 | [StringLength( 25 )] 13 | public string FirstName { get; set; } 14 | 15 | [Required] 16 | [StringLength( 25 )] 17 | public string LastName { get; set; } 18 | 19 | public string Email { get; set; } 20 | 21 | public string Phone { get; set; } 22 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Models/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Order 8 | { 9 | public int Id { get; set; } 10 | 11 | public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.Now; 12 | 13 | public DateTimeOffset EffectiveDate { get; set; } = DateTimeOffset.Now; 14 | 15 | [Required] 16 | public string Customer { get; set; } 17 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Models/Person.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | public class Person 8 | { 9 | public int Id { get; set; } 10 | 11 | [Required] 12 | [StringLength( 25 )] 13 | public string FirstName { get; set; } 14 | 15 | [Required] 16 | [StringLength( 25 )] 17 | public string LastName { get; set; } 18 | 19 | public string Email { get; set; } 20 | 21 | public string Phone { get; set; } 22 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Models/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.Models; 4 | 5 | public class WeatherForecast 6 | { 7 | public string Id { get; set; } 8 | 9 | public DateTime Date { get; set; } 10 | 11 | public double Temperature { get; set; } 12 | 13 | public string Summary { get; set; } 14 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/UsingConventions/ConventionsAcceptanceTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.UsingConventions; 4 | 5 | [Collection( "OData" + nameof( ConventionsTestCollection ) )] 6 | public abstract class ConventionsAcceptanceTest : ODataAcceptanceTest 7 | { 8 | protected ConventionsAcceptanceTest( ODataFixture fixture ) : base( fixture ) { } 9 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/UsingConventions/ConventionsTestCollection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData.UsingConventions; 4 | 5 | [CollectionDefinition( "OData" + nameof( ConventionsTestCollection ) )] 6 | public sealed class ConventionsTestCollection : ICollectionFixture 7 | { 8 | } -------------------------------------------------------------------------------- /src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Home Page 5 | 6 | 7 |

Home

8 |

Hello world!

9 | 10 | -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/ApiExplorer/ApiDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Microsoft.AspNetCore.Mvc.ApiExplorer; 4 | 5 | internal static class ApiDescriptionExtensions 6 | { 7 | internal static bool IsODataLike( this ApiDescription description ) 8 | { 9 | var parameters = description.ActionDescriptor.Parameters; 10 | 11 | for ( var i = 0; i < parameters.Count; i++ ) 12 | { 13 | if ( parameters[i].ParameterType.IsODataQueryOptions() ) 14 | { 15 | return true; 16 | } 17 | } 18 | 19 | return false; 20 | } 21 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/ApiExplorer/ModelMetadataExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | using Microsoft.AspNetCore.Mvc.ModelBinding; 6 | using System.Runtime.CompilerServices; 7 | 8 | internal static class ModelMetadataExtensions 9 | { 10 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 11 | internal static ModelMetadata SubstituteIfNecessary( this ModelMetadata modelMetadata, Type type ) 12 | { 13 | if ( type.Equals( modelMetadata.ModelType ) ) 14 | { 15 | return modelMetadata; 16 | } 17 | 18 | return new SubstitutedModelMetadata( modelMetadata, type ); 19 | } 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/Conventions/ODataQueryOptionSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | using Microsoft.AspNetCore.Mvc.ModelBinding; 6 | 7 | /// 8 | /// Provides additional implementation specific to Microsoft ASP.NET Core. 9 | /// 10 | [CLSCompliant( false )] 11 | public partial class ODataQueryOptionSettings 12 | { 13 | /// 14 | /// Gets or sets the configured model metadata provider. 15 | /// 16 | /// The configured model metadata provider. 17 | public IModelMetadataProvider? ModelMetadataProvider { get; set; } 18 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData.ApiExplorer/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 | Support OData 9.0 ([#1103](https://github.com/dotnet/aspnet-api-versioning/issues/1103)) -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData/Format.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Text; 6 | 7 | internal static class Format 8 | { 9 | internal static readonly CompositeFormat UnableToFindServices = CompositeFormat.Parse( SR.UnableToFindServices ); 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData/OData/IODataApiVersionCollectionProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | /// 6 | /// Defines the behavior of a provider that collects OData-specific API versions. 7 | /// 8 | public interface IODataApiVersionCollectionProvider 9 | { 10 | /// 11 | /// Gets or sets a list of all OData API versions. 12 | /// 13 | /// A read-only list of 14 | /// API versions. 15 | IReadOnlyList ApiVersions { get; set; } 16 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData/OData/ODataApiVersionCollectionProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable CA1812 5 | 6 | namespace Asp.Versioning.OData; 7 | 8 | internal sealed class ODataApiVersionCollectionProvider : IODataApiVersionCollectionProvider 9 | { 10 | private IReadOnlyList? apiVersions; 11 | 12 | public IReadOnlyList ApiVersions 13 | { 14 | get => apiVersions ?? Array.Empty(); 15 | set => apiVersions = value; 16 | } 17 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/src/Asp.Versioning.OData/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 | Support OData 9.0 ([#1103](https://github.com/dotnet/aspnet-api-versioning/issues/1103)) -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Asp.Versioning.OData.ApiExplorer.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(DefaultTargetFramework) 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/AllConfigurations.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Configuration; 4 | 5 | using Asp.Versioning.OData; 6 | using Microsoft.OData.ModelBuilder; 7 | 8 | /// 9 | /// Represents the model configuration for all configurations. 10 | /// 11 | public class AllConfigurations : IModelConfiguration 12 | { 13 | /// 14 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string routePrefix ) 15 | { 16 | ArgumentNullException.ThrowIfNull( builder ); 17 | 18 | builder.Function( "GetSalesTaxRate" ).Returns().Parameter( "PostalCode" ); 19 | } 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Configuration/ApiVersions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Configuration; 4 | 5 | using Asp.Versioning; 6 | 7 | internal static class ApiVersions 8 | { 9 | internal static readonly ApiVersion V1 = new( 1, 0 ); 10 | internal static readonly ApiVersion V2 = new( 2, 0 ); 11 | internal static readonly ApiVersion V3 = new( 3, 0 ); 12 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Models/Product.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | using System.ComponentModel.DataAnnotations.Schema; 6 | 7 | public class Product 8 | { 9 | public int Id { get; set; } 10 | 11 | public string Name { get; set; } 12 | 13 | public decimal Price { get; set; } 14 | 15 | public string Category { get; set; } 16 | 17 | [ForeignKey( nameof( Supplier ) )] 18 | public int? SupplierId { get; set; } 19 | 20 | public virtual Supplier Supplier { get; set; } 21 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.ApiExplorer.Tests/Simulators/Models/Supplier.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators.Models; 4 | 5 | public class Supplier 6 | { 7 | public int Id { get; set; } 8 | 9 | public string Name { get; set; } 10 | 11 | #pragma warning disable CA2227 // Collection properties should be read only 12 | public ICollection Products { get; set; } 13 | #pragma warning restore CA2227 // Collection properties should be read only 14 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Asp.Versioning.OData.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(DefaultTargetFramework) 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Simulators/Tests2Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Routing.Controllers; 8 | 9 | [ApiVersion( 2.0 )] 10 | [ControllerName( "Tests" )] 11 | public class Tests2Controller : ODataController 12 | { 13 | [EnableQuery] 14 | public IActionResult Get() => 15 | Ok( new TestEntity[] { new() { Id = 1 }, new() { Id = 2 }, new() { Id = 3 } } ); 16 | 17 | [EnableQuery] 18 | public IActionResult Get( int key ) => Ok( new TestEntity() { Id = key } ); 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Simulators/Tests3Controller.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Routing.Controllers; 8 | 9 | [ApiVersion( 3.0 )] 10 | [ApiVersion( 3.0, "Beta", Deprecated = true )] 11 | [ControllerName( "Tests" )] 12 | public class Tests3Controller : ODataController 13 | { 14 | [EnableQuery] 15 | public IActionResult Get() => 16 | Ok( new TestEntity[] { new() { Id = 1 }, new() { Id = 2 }, new() { Id = 3 } } ); 17 | 18 | [EnableQuery] 19 | public IActionResult Get( int key ) => Ok( new TestEntity() { Id = key } ); 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Simulators/TestsController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Routing.Controllers; 8 | 9 | [ApiVersion( 1.0 )] 10 | public class TestsController : ODataController 11 | { 12 | [EnableQuery] 13 | public IActionResult Get() => 14 | Ok( new TestEntity[] { new() { Id = 1 }, new() { Id = 2 }, new() { Id = 3 } } ); 15 | 16 | [EnableQuery] 17 | public IActionResult Get( int key ) => Ok( new TestEntity() { Id = key } ); 18 | } -------------------------------------------------------------------------------- /src/AspNetCore/OData/test/Asp.Versioning.OData.Tests/Simulators/VersionNeutralController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Simulators; 4 | 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.OData.Query; 7 | using Microsoft.AspNetCore.OData.Routing.Controllers; 8 | 9 | [ApiVersionNeutral] 10 | [ControllerName( "NeutralTests" )] 11 | public class VersionNeutralController : ODataController 12 | { 13 | [EnableQuery] 14 | public IActionResult Get() => 15 | Ok( new TestNeutralEntity[] { new() { Id = 1 }, new() { Id = 2 }, new() { Id = 3 } } ); 16 | 17 | [EnableQuery] 18 | public IActionResult Get( int key ) => Ok( new TestNeutralEntity() { Id = key } ); 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/ApiVersionMetadataCollationContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | /// 6 | /// Represents the context used during API version metadata collation. 7 | /// 8 | public class ApiVersionMetadataCollationContext 9 | { 10 | /// 11 | /// Gets the read-only list of collation results. 12 | /// 13 | /// The read-only list of collation results. 14 | public ApiVersionMetadataCollationCollection Results { get; } = []; 15 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/DefaultEndpointInspector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | 7 | /// 8 | /// Represents the default endpoint inspector. 9 | /// 10 | [CLSCompliant(false)] 11 | public sealed class DefaultEndpointInspector : IEndpointInspector 12 | { 13 | /// 14 | public bool IsControllerAction( Endpoint endpoint ) => false; 15 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/IApiVersionDescriptionProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | /// 6 | /// Defines the behavior of a provider that discovers and describes API version information within an application. 7 | /// 8 | public interface IApiVersionDescriptionProvider 9 | { 10 | /// 11 | /// Gets a read-only list of discovered API version descriptions. 12 | /// 13 | /// A read-only list of API version descriptions. 14 | IReadOnlyList ApiVersionDescriptions { get; } 15 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/IEndpointInspector.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | 7 | /// 8 | /// Defines the behavior of an endpoint inspector. 9 | /// 10 | [CLSCompliant( false )] 11 | public interface IEndpointInspector 12 | { 13 | /// 14 | /// Determines whether the specified endpoint is a controller action. 15 | /// 16 | /// The endpoint to inspect. 17 | /// True if the is for a controller action; otherwise, false. 18 | bool IsControllerAction( Endpoint endpoint ); 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Builder/ApiVersionSetBuilderFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Builder; 4 | 5 | /// 6 | /// Creates and returns a new API version set builder. 7 | /// 8 | /// The name of the API associated with the builder, if any. 9 | /// A new API version set builder. 10 | public delegate ApiVersionSetBuilder ApiVersionSetBuilderFactory( string? name = default ); -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Builder/IVersionedEndpointRouteBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Builder; 4 | 5 | using Asp.Versioning.Conventions; 6 | using Microsoft.AspNetCore.Builder; 7 | using Microsoft.AspNetCore.Routing; 8 | 9 | /// 10 | /// Defines the behavior of a versioned . 11 | /// 12 | [CLSCompliant( false )] 13 | public interface IVersionedEndpointRouteBuilder : 14 | IEndpointRouteBuilder, 15 | IEndpointConventionBuilder 16 | { 17 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/DependencyInjection/ApiVersioningBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Microsoft.Extensions.DependencyInjection; 4 | 5 | using Asp.Versioning; 6 | 7 | internal sealed class ApiVersioningBuilder : IApiVersioningBuilder 8 | { 9 | public ApiVersioningBuilder( IServiceCollection services ) => Services = services; 10 | 11 | public IServiceCollection Services { get; } 12 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/IApiVersioningBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | /// 8 | /// Defines the behavior for configuring API versioning. 9 | /// 10 | public partial interface IApiVersioningBuilder 11 | { 12 | /// 13 | /// Gets the services used when configuring API versioning. 14 | /// 15 | /// The service collection used 16 | /// by API versioning. 17 | IServiceCollection Services { get; } 18 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/ApiVersionPolicyFeature.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal sealed class ApiVersionPolicyFeature 6 | { 7 | public ApiVersionPolicyFeature( ApiVersionMetadata metadata ) => Metadata = metadata; 8 | 9 | public ApiVersionMetadata Metadata { get; } 10 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/EndpointType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal enum EndpointType 6 | { 7 | UserDefined, 8 | Malformed, 9 | Ambiguous, 10 | Unspecified, 11 | UnsupportedMediaType, 12 | AssumeDefault, 13 | NotAcceptable, 14 | Unsupported, 15 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/NotAcceptableEndpoint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | using static Microsoft.AspNetCore.Http.EndpointMetadataCollection; 7 | 8 | internal sealed class NotAcceptableEndpoint : Endpoint 9 | { 10 | private const string Name = "406 HTTP Not Acceptable"; 11 | 12 | internal NotAcceptableEndpoint( ApiVersioningOptions options ) 13 | : base( 14 | context => EndpointProblem.UnsupportedApiVersion( 15 | context, 16 | options, 17 | StatusCodes.Status406NotAcceptable ), 18 | Empty, 19 | Name ) { } 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/RouteDestination.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | internal struct RouteDestination 6 | { 7 | public readonly int Exit; 8 | public int Malformed; 9 | public int Ambiguous; 10 | public int Unspecified; 11 | public int Unsupported; 12 | public int UnsupportedMediaType; 13 | public int AssumeDefault; 14 | public int NotAcceptable; 15 | 16 | public RouteDestination( int exit ) 17 | { 18 | Exit = exit; 19 | Malformed = exit; 20 | Ambiguous = exit; 21 | Unspecified = exit; 22 | Unsupported = exit; 23 | UnsupportedMediaType = exit; 24 | AssumeDefault = exit; 25 | NotAcceptable = exit; 26 | } 27 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/UnsupportedMediaTypeEndpoint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Routing; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | using static Microsoft.AspNetCore.Http.EndpointMetadataCollection; 7 | 8 | internal sealed class UnsupportedMediaTypeEndpoint : Endpoint 9 | { 10 | private const string Name = "415 HTTP Unsupported Media Type"; 11 | 12 | internal UnsupportedMediaTypeEndpoint( ApiVersioningOptions options ) 13 | : base( 14 | context => EndpointProblem.UnsupportedApiVersion( 15 | context, 16 | options, 17 | StatusCodes.Status415UnsupportedMediaType ), 18 | Empty, 19 | Name ) { } 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Http/SunsetPolicyManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Microsoft.Extensions.Options; 6 | 7 | /// 8 | /// Provides additional content specific to ASP.NET Core. 9 | /// 10 | public partial class SunsetPolicyManager 11 | { 12 | private readonly IOptions options; 13 | 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The associated API versioning options. 18 | public SunsetPolicyManager( IOptions options ) => this.options = options; 19 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/FormatGroupNameCallback.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer; 4 | 5 | /// 6 | /// Represents a callback function used to format a group name. 7 | /// 8 | /// The associated group name. 9 | /// A formatted API version. 10 | /// The format result. 11 | public delegate string FormatGroupNameCallback( string groupName, string apiVersion ); -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/Internal/GroupedApiVersion.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer.Internal; 4 | 5 | internal record struct GroupedApiVersion( string? GroupName, ApiVersion ApiVersion ); -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/Internal/IGroupedApiVersionMetadata.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer.Internal; 4 | 5 | internal interface IGroupedApiVersionMetadata 6 | { 7 | string? GroupName { get; } 8 | 9 | string Name { get; } 10 | 11 | bool IsApiVersionNeutral { get; } 12 | 13 | ApiVersionModel Map( ApiVersionMapping mapping ); 14 | 15 | ApiVersionMapping MappingTo( ApiVersion? apiVersion ); 16 | 17 | bool IsMappedTo( ApiVersion? apiVersion ); 18 | 19 | void Deconstruct( out ApiVersionModel apiModel, out ApiVersionModel endpointModel ); 20 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/Internal/IGroupedApiVersionMetadataFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApiExplorer.Internal; 4 | 5 | internal interface IGroupedApiVersionMetadataFactory 6 | where T : IGroupedApiVersionMetadata 7 | { 8 | static abstract T New( string? groupName, ApiVersionMetadata metadata ); 9 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc.ApiExplorer/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApiVersionModelBinderProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Microsoft.AspNetCore.Mvc.ModelBinding; 6 | 7 | internal sealed class ApiVersionModelBinderProvider : IModelBinderProvider 8 | { 9 | private static ApiVersionModelBinder? binder; 10 | 11 | public IModelBinder? GetBinder( ModelBinderProviderContext context ) 12 | { 13 | ArgumentNullException.ThrowIfNull( context ); 14 | 15 | if ( typeof( ApiVersion ).IsAssignableFrom( context.Metadata.ModelType ) ) 16 | { 17 | binder ??= new(); 18 | return binder; 19 | } 20 | 21 | return default; 22 | } 23 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApplicationModels/NoControllerFilter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.ApplicationModels; 4 | 5 | using Microsoft.AspNetCore.Mvc.ApplicationModels; 6 | 7 | /// 8 | /// Represents an API controller filter that performs no filtering and includes all controllers. 9 | /// 10 | [CLSCompliant( false )] 11 | public sealed class NoControllerFilter : IApiControllerFilter 12 | { 13 | /// 14 | public IList Apply( IList controllers ) => controllers; 15 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ControllerNameAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Microsoft.AspNetCore.Mvc.Routing; 6 | 7 | /// 8 | /// Provides additional implementation specific to ASP.NET Core. 9 | /// 10 | [CLSCompliant( false )] 11 | public sealed partial class ControllerNameAttribute : RouteValueAttribute 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The name of the controller. 17 | public ControllerNameAttribute( string name ) : base( "controller", name ) => Name = name; 18 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/Conventions/DefaultControllerNameConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | using static ControllerNameConvention; 6 | 7 | /// 8 | /// Represents the default controller name convention. 9 | /// 10 | /// This convention will strip the Controller suffix as well as any trailing numeric values. 11 | public class DefaultControllerNameConvention : OriginalControllerNameConvention 12 | { 13 | /// 14 | public override string NormalizeName( string controllerName ) => 15 | TrimTrailingNumbers( base.NormalizeName( controllerName ) ); 16 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/Conventions/OriginalControllerNameConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | /// 6 | /// Provides additional implementation specific ASP.NET Core. 7 | /// 8 | public partial class OriginalControllerNameConvention 9 | { 10 | /// 11 | public virtual string NormalizeName( string controllerName ) => controllerName; // already normalized 12 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests/Asp.Versioning.Http.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(DefaultTargetFramework) 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests/ConstantApiVersionSelectorTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using Microsoft.AspNetCore.Http; 6 | 7 | public class ConstantApiVersionSelectorTest 8 | { 9 | [Fact] 10 | public void select_version_should_return_constant_value() 11 | { 12 | // arrange 13 | var request = Mock.Of(); 14 | var version = new ApiVersion( new DateOnly( 2016, 06, 22 ) ); 15 | var selector = new ConstantApiVersionSelector( version ); 16 | 17 | // act 18 | var selectedVersion = selector.SelectVersion( request, ApiVersionModel.Default ); 19 | 20 | // assert 21 | selectedVersion.Should().Be( version ); 22 | } 23 | } -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/test/Asp.Versioning.Mvc.ApiExplorer.Tests/Asp.Versioning.Mvc.ApiExplorer.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(DefaultTargetFramework) 5 | Asp.Versioning.ApiExplorer 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/AspNetCore/WebApi/test/Asp.Versioning.Mvc.Tests/Asp.Versioning.Mvc.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(DefaultTargetFramework) 5 | Asp.Versioning 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Client/src/Asp.Versioning.Http.Client/IApiVersionWriter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Http; 4 | 5 | /// 6 | /// Defines the behavior of an API version writer. 7 | /// 8 | public interface IApiVersionWriter 9 | { 10 | /// 11 | /// Write an API version to a request. 12 | /// 13 | /// The HTTP request to write the API version to. 14 | /// The API version to write. 15 | void Write( HttpRequestMessage request, ApiVersion apiVersion ); 16 | } -------------------------------------------------------------------------------- /src/Client/src/Asp.Versioning.Http.Client/README.md: -------------------------------------------------------------------------------- 1 | ASP.NET API versioning gives you a powerful, but easy-to-use method for adding API versioning semantics to your new 2 | and existing REST services built with ASP.NET. The API versioning extensions define simple metadata attributes and 3 | conventions that you use to describe which API versions are implemented by your services. 4 | 5 | ## Commonly Used Types 6 | 7 | - Asp.Versioning.ApiVersionHandler 8 | - Asp.Versioning.ApiVersionInformation 9 | - Asp.Versioning.ApiVersionWriter 10 | - Asp.Versioning.IApiNotification 11 | 12 | ## Release Notes 13 | 14 | -------------------------------------------------------------------------------- /src/Client/src/Asp.Versioning.Http.Client/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/Client/test/Asp.Versioning.Http.Client.Tests/Asp.Versioning.Http.Client.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(DefaultTargetFramework);net452;net472 5 | Asp.Versioning.Http 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Common/src/Common.ApiExplorer/Resources.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | internal static class Resources 6 | { 7 | #if NETFRAMEWORK 8 | public const string BaseName = "Asp.Versioning.ExpSR"; 9 | #else 10 | public const string BaseName = "Asp.Versioning.ApiExplorer.ExpSR"; 11 | #endif 12 | } -------------------------------------------------------------------------------- /src/Common/src/Common.Backport/Array.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Runtime.CompilerServices; 6 | 7 | internal static class Array 8 | { 9 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 10 | public static T[] Empty() => new T[0]; 11 | } -------------------------------------------------------------------------------- /src/Common/src/Common.Backport/CallerArgumentExpressionAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | // REF: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CallerArgumentExpressionAttribute.cs 4 | namespace System.Runtime.CompilerServices 5 | { 6 | [AttributeUsage( AttributeTargets.Parameter, AllowMultiple = false, Inherited = false )] 7 | internal sealed class CallerArgumentExpressionAttribute : Attribute 8 | { 9 | public CallerArgumentExpressionAttribute( string parameterName ) 10 | { 11 | ParameterName = parameterName; 12 | } 13 | 14 | public string ParameterName { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Common/src/Common.Backport/Common.Backport.msbuildproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard1.0 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Common/src/Common.Mvc/Common.Mvc.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 6629a038-4ff4-45fa-8d32-3a640d831601 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/src/Common.Mvc/Conventions/ExpressionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | using System.Globalization; 6 | using System.Linq.Expressions; 7 | using System.Reflection; 8 | 9 | internal static class ExpressionExtensions 10 | { 11 | internal static MethodInfo ExtractMethod( this Expression expression ) 12 | { 13 | if ( expression.Body is MethodCallExpression methodCall ) 14 | { 15 | return methodCall.Method; 16 | } 17 | 18 | var message = string.Format( CultureInfo.CurrentCulture, MvcFormat.InvalidActionMethodExpression, expression ); 19 | throw new InvalidOperationException( message ); 20 | } 21 | } -------------------------------------------------------------------------------- /src/Common/src/Common.Mvc/Conventions/OriginalControllerNameConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions; 4 | 5 | /// 6 | /// Represents the original controller name convention. 7 | /// 8 | /// This convention will apply the original convention which only strips the Controller suffix. 9 | public partial class OriginalControllerNameConvention : IControllerNameConvention 10 | { 11 | /// 12 | public virtual string GroupName( string controllerName ) => controllerName; 13 | } -------------------------------------------------------------------------------- /src/Common/src/Common.OData.ApiExplorer/Conventions/ODataActionQueryOptionConventionLookup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.Conventions 4 | { 5 | using System.Reflection; 6 | 7 | internal delegate bool ODataActionQueryOptionConventionLookup( 8 | MethodInfo action, 9 | ODataQueryOptionSettings settings, 10 | out IODataQueryOptionsConvention? convention ); 11 | } -------------------------------------------------------------------------------- /src/Common/src/Common.OData.ApiExplorer/NullableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace System; 4 | 5 | using System.Runtime.CompilerServices; 6 | 7 | internal static class NullableExtensions 8 | { 9 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 10 | public static bool Unset( this int? value ) => value.HasValue && value.Value == 0; 11 | 12 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 13 | public static bool NoLimitOrSome( this int? value ) => !value.HasValue || value.Value > 0; 14 | 15 | [MethodImpl( MethodImplOptions.AggressiveInlining )] 16 | public static bool NoLimitOrNone( this int? value ) => !value.HasValue || value.Value <= 0; 17 | } -------------------------------------------------------------------------------- /src/Common/src/Common.OData/Common.OData.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 1ed0d3ef-16a1-40d1-a3dc-978df1eb7d3f 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/src/Common.OData/OData/AdHocAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | /// 6 | /// Represents an annotation for ad hoc usage. 7 | /// 8 | public sealed class AdHocAnnotation 9 | { 10 | /// 11 | /// Gets a singleton instance of the annotation. 12 | /// 13 | /// A singleton annotation instance. 14 | public static AdHocAnnotation Instance { get; } = new(); 15 | } -------------------------------------------------------------------------------- /src/Common/src/Common.OData/OData/DelegatingModelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | #if NETFRAMEWORK 6 | using Microsoft.AspNet.OData.Builder; 7 | #else 8 | using Microsoft.OData.ModelBuilder; 9 | #endif 10 | 11 | internal sealed class DelegatingModelConfiguration : IModelConfiguration 12 | { 13 | private readonly Action action; 14 | 15 | internal DelegatingModelConfiguration( Action action ) => this.action = action; 16 | 17 | public void Apply( ODataModelBuilder builder, ApiVersion apiVersion, string? routePrefix ) => action( builder, apiVersion, routePrefix ); 18 | } -------------------------------------------------------------------------------- /src/Common/src/Common.ProblemDetails/Common.ProblemDetails.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 0fa0aa78-4356-4593-854a-e9698d27ab3d 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/src/Common.TypeInfo/Common.TypeInfo.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 7a5f3994-0df5-48b5-af3d-3f88a1d4eb04 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Common/src/Common/Common.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | a2df7cb6-142e-43d0-82c0-47ad5e89f4e3 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/src/Common/UriExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | internal static class UriExtensions 6 | { 7 | internal static string SafeFullPath( this Uri uri ) => uri.GetLeftPart( UriPartial.Path ); 8 | } -------------------------------------------------------------------------------- /src/Common/test/Common.Mvc.Tests/Common.Mvc.Tests.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | e3e486e4-107b-488f-835b-d53a727c2c5e 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/test/Common.Mvc.Tests/ControllerNameAttributeTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | public class ControllerNameAttributeTest 6 | { 7 | [Fact] 8 | public void new_controller_name_attribute_should_set_name() 9 | { 10 | // arrange 11 | var expected = "Test"; 12 | 13 | // act 14 | var attribute = new ControllerNameAttribute( expected ); 15 | 16 | // assert 17 | attribute.Name.Should().Be( expected ); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Address.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | public class Address 6 | { 7 | public int AddressId { get; set; } 8 | 9 | public string Street { get; set; } 10 | 11 | public string City { get; set; } 12 | 13 | public string State { get; set; } 14 | 15 | public string Zip { get; set; } 16 | 17 | public string IsoCode { get; set; } 18 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/AllowedRolesAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | [AttributeUsage( AttributeTargets.Property )] 6 | public sealed class AllowedRolesAttribute : Attribute 7 | { 8 | public AllowedRolesAttribute( params string[] allowedRoles ) 9 | { 10 | AllowedRoles = allowedRoles.ToList(); 11 | } 12 | 13 | public IReadOnlyList AllowedRoles { get; } 14 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Company.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable CA1002 // Do not expose generic lists 5 | #pragma warning disable CA2227 // Collection properties should be read only 6 | 7 | namespace Asp.Versioning.OData; 8 | 9 | public class Company 10 | { 11 | public int CompanyId { get; set; } 12 | 13 | public Company ParentCompany { get; set; } 14 | 15 | public List Subsidiaries { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public DateTime DateFounded { get; set; } 20 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Contact.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable CA1002 // Do not expose generic lists 5 | #pragma warning disable CA2227 // Collection properties should be read only 6 | 7 | namespace Asp.Versioning.OData; 8 | 9 | public class Contact 10 | { 11 | public int ContactId { get; set; } 12 | 13 | public string FirstName { get; set; } 14 | 15 | public string LastName { get; set; } 16 | 17 | public string Email { get; set; } 18 | 19 | public string Phone { get; set; } 20 | 21 | public List
Addresses { get; set; } 22 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Employee.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | public class Employee 6 | { 7 | public int EmployeeId { get; set; } 8 | 9 | public Employer Employer { get; set; } 10 | 11 | [AllowedRoles( "Manager", "Employer" )] 12 | public decimal Salary { get; set; } 13 | 14 | public string FirstName { get; set; } 15 | 16 | public string LastName { get; set; } 17 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Employer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | #pragma warning disable IDE0079 4 | #pragma warning disable CA2227 // Collection properties should be read only 5 | 6 | namespace Asp.Versioning.OData; 7 | 8 | public class Employer 9 | { 10 | public int EmployerId { get; set; } 11 | 12 | public ICollection Employees { get; set; } 13 | 14 | public DateTime Birthday { get; set; } 15 | 16 | public string FirstName { get; set; } 17 | 18 | public string LastName { get; set; } 19 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.ApiExplorer.Tests/OData/Shipment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | public class Shipment 6 | { 7 | public int Id { get; set; } 8 | 9 | public DateTime ShippedOn { get; set; } 10 | 11 | public double Weight { get; set; } 12 | 13 | public Address Destination { get; set; } 14 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.Tests/Common.OData.Tests.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 62c25010-2f1d-4146-bdfc-89831d5993d4 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/test/Common.OData.Tests/OData/ApiVersionAnnotationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning.OData; 4 | 5 | public class ApiVersionAnnotationTest 6 | { 7 | [Fact] 8 | public void new_api_version_annotation_should_set_expected_version() 9 | { 10 | // arrange 11 | var annotatedApiVersion = new ApiVersion( 1, 1 ); 12 | var annotation = new ApiVersionAnnotation( annotatedApiVersion ); 13 | 14 | // act 15 | var apiVersion = annotation.ApiVersion; 16 | 17 | // assert 18 | apiVersion.Should().Be( annotatedApiVersion ); 19 | } 20 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.Tests/TestEntity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | public class TestEntity 6 | { 7 | public int Id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/Common/test/Common.OData.Tests/TestNeutralEntity.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | public class TestNeutralEntity 6 | { 7 | public int Id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/Common/test/Common.Tests/Common.Tests.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | feb58f0f-cfde-4da7-9336-af593e33634f 7 | 8 | 9 | Asp.Versioning 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Common/test/Common.Tests/SelectVersionData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. 2 | 3 | namespace Asp.Versioning; 4 | 5 | using System.Collections; 6 | 7 | public abstract class SelectVersionData : IEnumerable 8 | { 9 | public abstract IEnumerator GetEnumerator(); 10 | 11 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 12 | 13 | protected static IEnumerable Supported( params ApiVersion[] versions ) => versions.AsEnumerable(); 14 | 15 | protected static IEnumerable Deprecated( params ApiVersion[] versions ) => versions.AsEnumerable(); 16 | 17 | protected static ApiVersion Expected( ApiVersion version ) => version; 18 | } --------------------------------------------------------------------------------