From c7c752206e9ede271eb902f22a6767104b625212 Mon Sep 17 00:00:00 2001 From: recalcitrantsupplant Date: Mon, 11 Nov 2024 09:38:29 +1000 Subject: [PATCH] feat: add "subscription-key" as query parameter, to support Azure and other APIs that wish to use API keys. --- prez/dependencies.py | 1 + prez/models/query_params.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/prez/dependencies.py b/prez/dependencies.py index 561a99e9..8f454a48 100755 --- a/prez/dependencies.py +++ b/prez/dependencies.py @@ -599,6 +599,7 @@ async def check_unknown_params(request: Request): "filter", "order_by", "order_by_direction", + "subscription-key", } unknown_params = set(request.query_params.keys()) - known_params if unknown_params: diff --git a/prez/models/query_params.py b/prez/models/query_params.py index ac24fb0c..a5657d1c 100755 --- a/prez/models/query_params.py +++ b/prez/models/query_params.py @@ -160,6 +160,11 @@ def __init__( default=None, description="Optional: Order direction, must be 'ASC' or 'DESC'", ), + subscription_key: str = Query( + default=None, + description="An optional API Subscription key", + alias="subscription-key", + ), ): self.q = q self.page = page @@ -172,6 +177,7 @@ def __init__( self.order_by_direction = order_by_direction self.filter = filter self.mediatype = mediatype + self.subscription_key = subscription_key self.validate_filter() def validate_filter(self):