-
-
Save pelzhaus/fac5e11b68767385850fc87ef1ba2403 to your computer and use it in GitHub Desktop.
A sample FastAPI route that uses the include_in_schema flag to only include the route in our OpenAPI spec in our staging environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from fastapi import APIRouter, Request | |
from pinwheel import settings | |
from pinwheel.models import PrivateModel | |
from pinwheel.managers import get_private_model | |
router = APIRouter() | |
@router.get( | |
"/{object_id}", | |
response_model=PrivateModel, | |
include_in_schema=settings.ENV == "staging" | |
) | |
def private_route( | |
request: Request, | |
object_id: uuid.UUID | |
): | |
return get_private_model(object_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment