File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 1- import json
21from http import HTTPStatus
32from typing import Annotated
43from typing import Any
109from fastapi import Query
1110from fastapi import Request
1211from fastapi import Response
12+ from fastapi .responses import JSONResponse
1313from pydantic import ValidationError
1414
1515from scim2_models import Context
4545app = FastAPI ()
4646
4747
48- class SCIMResponse (Response ):
48+ class SCIMResponse (JSONResponse ):
4949 """SCIM JSON response that auto-extracts the ``ETag`` from ``meta.version``."""
5050
5151 media_type = "application/scim+json"
5252
53- def render (self , content : Any ) -> bytes :
54- self ._etag = (content or {}).get ("meta" , {}).get ("version" )
55- return json .dumps (content , ensure_ascii = False ).encode ("utf-8" )
56-
5753 def __init__ (self , content : Any = None , ** kwargs : Any ) -> None :
5854 super ().__init__ (content , ** kwargs )
59- if self ._etag :
60- self .headers ["ETag" ] = self ._etag
55+ if meta := (content or {}).get ("meta" , {}):
56+ if version := meta .get ("version" ):
57+ self .headers ["ETag" ] = version
6158
6259
6360router = APIRouter (prefix = "/scim/v2" , default_response_class = SCIMResponse )
You can’t perform that action at this time.
0 commit comments