Skip to content

Instantly share code, notes, and snippets.

@pelzhaus
Created March 25, 2021 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelzhaus/fac5e11b68767385850fc87ef1ba2403 to your computer and use it in GitHub Desktop.
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.
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