2
votes

I am implementing a Wagtail powered blog within a larger (primarily DRF) driven app. I'm attempting to use drf-yasg for my documentation.

Since installing wagtail, the docs are now throwing

'Request' object has no attribute 'wagtailapi_router'

It looks to be related to the introspection that drf-yasg does, and all I can find about excluding views from drf-yasg is done at the code level. Being an installed module obviously I want to avoid that.

Has anyone got these 2 (3) components playing nicely together?

1

1 Answers

1
votes

It's been a very long time since you asked this question, but as I found this while looking for an answer myself, I thought I might share what worked for me.

Note that I'm not using drf-yasg, but rather DRF's own schema generator. They do however have a lot in common.

The problem in my case was that the schema generator URL was defined like this:

path(
    "schema/",
    get_schema_view(title="My API Schema"),
    name="openapi-schema",
),

What I needed to add was a patterns= argument that referenced my API specifically, leaving out the other non-API urls (like Wagtail):

path(
    "v3/schema/",
    get_schema_view(title="My API Schema", patterns=router.urls),
    name="openapi-schema",
),

I hope that helps... someone :-D