Drf-yasg: Can I exclude internal APIs?

Created on 1 Oct 2019  路  2Comments  路  Source: axnsan12/drf-yasg

Hello. Sorry if exists solution, I not found it.

I have internal API e.g. callbacks for payments, I don't want to show them in swagger, how I can hide them?

Like that: https://github.com/marcgibbons/django-rest-swagger/issues/64

Most helpful comment

If you use get_schema_view, it accept patterns. You can divide your patterns and just give those you want to expose.

I did it like so

schema_view = get_schema_view(
    openapi.Info(
        title="API",
        default_version="v1",
        description="blablabla",
    ),
    public=True,
    patterns=[url(r"^api/v1/", include((public_router.urls, "api"), namespace="v1"))],
)

where public_router only has viewsets that I want to show.

All 2 comments

If you use get_schema_view, it accept patterns. You can divide your patterns and just give those you want to expose.

I did it like so

schema_view = get_schema_view(
    openapi.Info(
        title="API",
        default_version="v1",
        description="blablabla",
    ),
    public=True,
    patterns=[url(r"^api/v1/", include((public_router.urls, "api"), namespace="v1"))],
)

where public_router only has viewsets that I want to show.

@webjunkie thank you, this it :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gertjanol picture gertjanol  路  5Comments

mkurnikov picture mkurnikov  路  3Comments

therefromhere picture therefromhere  路  3Comments

mkurnikov picture mkurnikov  路  4Comments

phihag picture phihag  路  3Comments