Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create sub-folder in the generated docs? #1188

Open
hexmo opened this issue Feb 27, 2024 · 3 comments
Open

How to create sub-folder in the generated docs? #1188

hexmo opened this issue Feb 27, 2024 · 3 comments

Comments

@hexmo
Copy link

hexmo commented Feb 27, 2024

image

In my project, the APIs for the Admin user start with api-admin followed by the resource-name.

For eg:

router = DefaultRouter()
router.register("api-admin/academic-document-names", AdminAcademicDocumentNameViewSet)
router.register("academic-document-names", PublicAcademicDocumentNameViewSet)
router.register("api-admin/academic-documents", AdminAcademicDocumentViewSet)

urlpatterns = [
    path("", include(router.urls)),
]

So I want to display routes for academic-document-names inside api-admin/academic-document-names instead for displaying every endpoints followed by api-admin into one single giant folder. How do I achieve this?

@tfranzel
Copy link
Owner

I'm no expert on redoc, but usually grouping happens through tags. auto-tagging works like this by default:

# A regex specifying the common denominator for all operation paths. If
# SCHEMA_PATH_PREFIX is set to None, drf-spectacular will attempt to estimate
# a common prefix. Use '' to disable.
# Mainly used for tag extraction, where paths like '/api/v1/albums' with
# a SCHEMA_PATH_PREFIX regex '/api/v[0-9]' would yield the tag 'albums'.
'SCHEMA_PATH_PREFIX': None,

either change that setting or manually tag your viewsets like:

@extend_schema(tags=["academic-document-names"])
class AdminAcademicDocumentNameViewSet():
   ...

@hexmo
Copy link
Author

hexmo commented Mar 1, 2024

I was only able to create root-level folders using tags. No sub-folders.

@tfranzel
Copy link
Owner

tfranzel commented Mar 1, 2024

Not even sure they support this. Details about redocly are out of scope for us. We just provide convenient access.

They might have some x- extensions for this but I don't know. Extensions can be added with @extend_schema(extensions=...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants