Versioning
Versioning¶
Versioning allows you to have different versions of your controllers or individual routes running within the same application. Applications change very often and it is not unusual that there are breaking changes that you need to make while still needing to support the previous version of the application.
There are 4 types of versioning that are supported:
URI Versioning |
The version will be passed within the URI of the request (default) |
Header Versioning |
A custom request header will specify the version |
Media Type Versioning |
The Accept header of the request will specify the version |
Custom Versioning |
Any aspect of the request may be used to specify the version(s). A custom function is provided to extract said version(s). |
URI Versioning Type¶
URI Versioning uses the version passed within the URI of the request, such as https://example.com/v1/route and https://example.com/v2/route.
Notice With URI Versioning the version will be automatically added to the URI after the global path prefix (if one exists), and before any controller or route paths.
To enable URI Versioning for your application, do the following:
main.py | |
---|---|
Notice The version in the URI will be automatically prefixed with
v
by default, however the prefix value can be configured by setting theprefix
key to your desired prefix orfalse
if you wish to disable it.info Hint The
VersioningType
enum is available to use for thetype
property and is imported from thenest.common
package.
Header Versioning Type¶
[ ... ]
Media Type Versioning Type¶
[ ... ]
Custom Versioning Type¶
[ ... ]
Usage¶
[ ... ]
Controller versions¶
[ ... ]
Route versions¶
[ ... ]
Multiple versions¶
[ ... ]
Version "Neutral"¶
[ ... ]
Global default version¶
If you do not want to provide a version for each controller/or individual routes, or if you want to have a specific version set as the default version for every controller/route that don't have the version specified, you could set the defaultVersion
as follows:
main.py | |
---|---|
Middleware versioning¶
[ ... ]