Comments (3)
I was trying to find the release notes on this, but I'm not finding them. UseApiBehavior
was introduced to support backward compatibility for <= 2.1
. It was originally false
and later defaulted to true
. It was always to slated to be removed at some point. I think that happened in 6.0
and I just forgot to call it out.
The first question is how you are using UseApiBehavior
. If you're explicitly setting it to true
, that's the default and current behavior. There's nothing for you to do. You're migrated. 😄
If you're setting it to false
, that still exists, but is unusual. The entire point of UseApiBehavior
was to make it easy to filter API controllers. Setting the configuration value to false
implies that you are using API Versioning for non-API controllers. This is supported for people that want to do that, but is a bit of an odd case.
At the same time that UseApiBehavior
was introduced, two new services were also introduced:
IApiControllerFilter
- filter down all controllers to just API controllersIApiControllerSpecification
- identify an API controller
There are two built-in specifications one for detecting API controllers by looking for whether the ApiControllerAttribute
has been applied (aka API Behaviors). This can be applied at the controller or assembly level. The second is looking for OData controllers (if you're usng it). The default filter accepts all specifications and removes any that are not satisfied. The old UseApiBehavior = false
was a shortcut to not using any filtering.
If you truly need custom filtering, you can replace any of the services and/or provide custom filters or specifications. If all you want is the equivalence of UseApiBehavior = false
, then an empty filter is provided out-of-the-box that you can use to replace the default service like this:
builder.Services.AddTransient<IApiControllerFilter, NoControllerFilter>();
builder.Services.AddApiVersioning();
I will make it a point to add some additional information about this in the migration guide.
A similar question was asked on SO:
https://stackoverflow.com/questions/76602962/what-does-useapibehavior-property-do-in-the-apiversioning-library
from aspnet-api-versioning.
Hi thanks for the detailed explanation. As it seems we don t need it anymore and was legacy from the beginning of the project
from aspnet-api-versioning.
I've added a section about API Behaviors in the migration guide. Hopefully, that help clear things up and helps other people migrating.
from aspnet-api-versioning.
Related Issues (20)
- .net 8 support HOT 7
- Breaking changes when migrating to OData8 + new versioning HOT 10
- odata/$metadata returns 404 when all controllers are decorated with ApiVersionNeutralAttribute HOT 3
- AddVersionedApiExplorer not working in Asp.Versioning HOT 5
- VersionedApiDescriptionProvider does not set the correct SunsetPolicy to ApiDescription instances HOT 1
- Using ApiExplorerSettingsAttribute together with ApiVersionAttribute produces unexpected number of ApiVersionDescriptions HOT 5
- Asp.Net Core WebApi - AWS ECS Cluster Authentication failure HOT 2
- [Versioned Clients][API Notifications] Fails to read new versions when available HOT 2
- Swashbuckle documentation inconsistent with examples HOT 2
- AssumeDefaultVersionWhenUnspecified does not work correctly if ApiVersionNeutral is used in the controller HOT 2
- swagger.json file not found after update HOT 9
- My API is not displaying all the versions. HOT 4
- Improve docs for HeaderApiVersionReader
- Add synonym to `AddMvc` method. HOT 7
- CurrentImplementationApiVersionSelector behaves differently based on whether an operation still exists on latest API version HOT 3
- The error 'code' is not included in the error response when using AddErrorObjects() HOT 2
- .NET 8 ASP Versioning is allowing any version number to be passed in to api request and returns data. HOT 5
- Native AoT trim analysis warning : WithLinkGeneratorDecorator
- Using URL segment versioning breaks Swagger generation HOT 3
- Documentation: Default value for ApiVersionReader is misleading
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnet-api-versioning.