Django Rest API complain about swagger version

We are using DJango rest framework to make api. We added swagger page, but its complain about swagger version.

Unable to render this definition

The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).

I was following documentation

Below are files.

from django.urls import path
urlpatterns = [
    path("openapi", get_schema_view(
            title="My api",
            description="API for me",
        ), name="openapi-schema"),
    path('swagger-ui/', TemplateView.as_view(
    ), name='swagger-ui')


<!DOCTYPE html>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="//" />
    <div id="swagger-ui"></div>
    <script src="//"></script>
    const ui = SwaggerUIBundle({
        url: "{% url schema_url %}",
        dom_id: '#swagger-ui',
        presets: [
        layout: "BaseLayout",
        requestInterceptor: (request) => {
          request.headers['X-CSRFToken'] = "{{ csrf_token }}"
          return request;

I think, its complaining about version: 1.0.0 mentioned in openapi schema view. But need to sure, if something else is not causing this issue.

Back to Top