sanic-org / sanic-ext

Extended Sanic functionality
https://sanic.dev/en/plugins/sanic-ext/getting-started.html
MIT License
50 stars 36 forks source link

[Question] OpenAPI spec available on all subdomains, and route exclusion without decorators does not seem to work. #223

Open nicolaipre opened 1 year ago

nicolaipre commented 1 year ago

Is it possible to exclude a route from the OpenAPI spec without using decorators? I found information in the docs about excluding routes, but it did not work:

group = Blueprint(name, url_prefix=prefix, host=subdomain)

if not in_schema:
    openapi.exclude(bp=group)

I also use subdomains and noticed that the Redoc endpoint is available for every subdomain with the default path. Is it possible to reference the Blueprint directly instead of using app.config.OAS_URI_TO_* to set the path?

Ideally something like this (where RedocBlueprint is the blueprint which app.config.OAS_URI_TO_REDOC sends you to):

# Custom route registration because I do not want decorators
RouteGroup(
    subdomain="api",
    middleware=[""],
    name="API-Information", 
    #prefix="",
    routes=[
        GET("/docs", RedocBlueprint).name("Redoc"),
    ]
),

Goals:

I believe* this used to work with the old sanic-openapi:

from sanic_openapi import openapi3_blueprint

Is there any way I can disable the spec generation and Blueprint creation done by Sanic-ext, and manually handle this instead so I can register the blueprint and set a path to it myself?