Output multiple API versions in one schema (path/namespace versioning only)
See original GitHub issueDescribe the bug
My team is trying to upgrade from 0.14.0 to 0.17.0.
In https://github.com/tfranzel/drf-spectacular/commit/2eaac13889624bffef208c7a401c33a8a472b194#diff-136013649b2fdf2f5496f11ae4591a56cc9d5d340869338b544905cb40b608f4L216, the ability to get the API version from the request was removed.
We used the GET_MOCK_REQUEST
setting to set the version on the request that the generator would use. Because our team uses namespace versioning, we could extract something like v2
from a path like /v2/some-resource/
.
The effect of this removal is that the operation_matches_version
check fails (https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/generators.py#L222) and endpoints that aren’t the default version are skipped in the output.
Expected behavior
I would expect to have a generated schema that includes multiple versions of an endpoint if they exist.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks for clarifying what you meant by safely. I wasn’t thinking about header based versioning and I agree this would not be safe for that.
Since we’ve got a workaround that makes this scheme work for our team, I can close the issue if you want. Or we can leave it open if you think it would be reasonable to support this kind of namespace versioning pattern as a feature request in the future.
aweome! glad your found a solution. i’ll rename the issue and leave it open for future reference. i can see this feature happening with 1-2 more independent requests.