AutoSchema fails when set on detail_route · Issue #5630 · encode/django-rest-framework (original) (raw)

Checklist

Steps to reproduce

  1. Create a view with a detail_route with a schema kwarg
        class AViewSet(GenericViewSet):
            @detail_route(schema=AutoSchema(manual_fields=[
                coreapi.Field(
                    "my_extra_field",
                    required=True,
                    location="path",
                    schema=coreschema.String()
                ),
            ]))
            def a_detail_route(self, request, my_normal_field):
                pass
  1. Register the view with a router
        router = routers.SimpleRouter()
        router.register(r'detail', AViewSet, base_name='detail')
        routes = router.urls
  1. Attempt to generate a schema from the view
        callback = routes[0].callback
        generator = SchemaGenerator()
        view = generator.create_view(callback, 'GET')
        link = view.schema.get_link('/a/url/{id}/', 'GET', '')

Expected behavior

A schema is generated for the detail route using the given AutoSchema.

Actual behavior

Crashes:
AttributeError: 'AutoSchema' object has no attribute '_view'