Search code examples
djangoswaggerdrf-spectacular

Django drf-spectacular - Can you exclude specific paths?


We have a bunch of api's with different versions in urls.py, eg

  • api/v1
  • api/v2
  • api/v3

. We want to implement swagger with drf-spectacular, but we only want to expose api/v3 endpoints.

Is there a way to do this? I cannot make sense of the documentation.

Thanks


Solution

  • Worked it out. Copied the custom preprocessing hook function, changed the pass statement to filter what I did not require in the endpoints, then mapped the location of the file and function in my spectacular settings for preprocessed hooks.