drf_openapi icon indicating copy to clipboard operation
drf_openapi copied to clipboard

improve versioning schemes support

Open trik opened this issue 7 years ago • 4 comments
trafficstars

close #98

view_config decorator now gets version using determine_version method of ApiView (vs version keyword argument which is not set eg. with AcceptHeaderVersioning)

close #71

with this schemes support improvement, drf_openapi's urls can be imported without a version parameter in url if REST_FRAMEWORK['DEFAULT_VERSION'] is set

trik avatar Feb 02 '18 14:02 trik

@trik I've just tested this but it seems you still need to specify the version as url(r'^(?P<version>(v1))/', include('drf_openapi.urls')),. This is required by <redoc spec-url='{% url 'api_schema' version=request.version %}?format=openapi'></redoc>.

I haven't tried #93 yet but that seems to cover it.

ju5t avatar Feb 10 '18 23:02 ju5t

@ju5t how did you test it? which versioning scheme did you use for testing?

when using AcceptHeaderVersioning scheme, you have to set version in Accept http header to get a specific version

schermata 2018-02-12 alle 11 03 23

if you mean that you can't render api docs using the default drf_openapi template, yeah it's true, but #93 doesn't seem a good solution for AcceptHeaderVersioning anyway, because i'm still forced to define a version keyword argument which is quite non-sense for this scheme maybe we could add a version or force_version GET parameter

trik avatar Feb 12 '18 10:02 trik

@trik AcceptHeaderVersioning. We have DEFAULT_VERSION set too. If we don't specify a header it should still be able to render the docs, I think?

ju5t avatar Feb 12 '18 13:02 ju5t

@ju5t not with the current template, unless you specify a version keyword argument in url

trik avatar Feb 13 '18 07:02 trik