5050META_RELATED_RECORDS_KEY = "records"
5151META_FAILED_RECORDS_KEY = "invalid"
5252META_VALIDATION_MESSAGES_KEY = "messages"
53+ OPENAPI_WHERE_OVERRIDE = {
54+ "parameters" : [
55+ {
56+ "name" : "where" ,
57+ "in" : "query" ,
58+ "description" : "Filter Query (JSON Object or Array of Objects)" ,
59+ "required" : False ,
60+ "schema" : {
61+ "type" : "string" ,
62+ "title" : "Where" ,
63+ "contentSchema" : {
64+ "title" : "Where" ,
65+ "type" : "object" ,
66+ "additionalProperties" : {"type" : "string" },
67+ },
68+ },
69+ }
70+ ]
71+ }
5372# -------------------------------------------------------------------------------------------
5473# ACTION MAP (FOR REUSE IN CLIENT CODE)
5574# -------------------------------------------------------------------------------------------
@@ -98,7 +117,7 @@ def __init__(
98117 self .repository = repository
99118 self .disable_nested_objects = disable_nested_objects
100119
101- async def create (request : Request , data : create_model ):
120+ async def create (request : Request , data : create_model ): # type: ignore
102121 the_thing_with_rels : CruddyGenericModel = getattr (data , single_name )
103122 context_data = {DATA_KEY : the_thing_with_rels , META_KEY : None }
104123 # If there is a user space lifecycle hook, run it (allows context mutations)
@@ -175,7 +194,7 @@ async def create(request: Request, data: create_model):
175194 return single_schema (** context_data )
176195
177196 async def update (
178- request : Request , id : id_type = Path (..., alias = "id" ), * , data : update_model
197+ request : Request , id : id_type = Path (..., alias = "id" ), * , data : update_model # type: ignore
179198 ):
180199 the_thing_with_rels : CruddyGenericModel = getattr (data , single_name )
181200 context_data = {DATA_KEY : the_thing_with_rels , META_KEY : {META_ID_KEY : id }}
@@ -290,7 +309,7 @@ async def delete(
290309 async def get_by_id (
291310 request : Request ,
292311 id : id_type = Path (..., alias = "id" ),
293- where : Json = Query (None , alias = "where" ),
312+ where : Json = Query (None , alias = "where" , include_in_schema = False ),
294313 ):
295314 context_data = {
296315 DATA_KEY : {
@@ -324,7 +343,7 @@ async def get_all(
324343 limit : int = self .default_limit ,
325344 columns : list [str ] = Query (None , alias = "columns" ),
326345 sort : list [str ] = Query (None , alias = "sort" ),
327- where : Json = Query (None , alias = "where" ),
346+ where : Json = Query (None , alias = "where" , include_in_schema = False ),
328347 ):
329348 context_data = {
330349 DATA_KEY : {
@@ -696,12 +715,13 @@ def _ControllerConfigManyToOne(
696715 policies_get_one ,
697716 config .foreign_resource .policies ["get_one" ],
698717 ),
718+ openapi_extra = OPENAPI_WHERE_OVERRIDE ,
699719 )
700720 async def get_many_to_one (
701721 request : Request ,
702722 id : id_type = Path (..., alias = "id" ),
703723 columns : list [str ] = Query (None , alias = "columns" ),
704- where : Json = Query (None , alias = "where" ),
724+ where : Json = Query (None , alias = "where" , include_in_schema = False ),
705725 ):
706726 origin_record : CruddyModel | None = await repository .get_by_id (
707727 id = id , request = request
@@ -849,6 +869,7 @@ def _ControllerConfigOneToMany(
849869 policies_get_one ,
850870 config .foreign_resource .policies ["get_many" ],
851871 ),
872+ openapi_extra = OPENAPI_WHERE_OVERRIDE ,
852873 )
853874 async def get_one_to_many (
854875 request : Request ,
@@ -857,7 +878,7 @@ async def get_one_to_many(
857878 limit : int = default_limit ,
858879 columns : list [str ] = Query (None , alias = "columns" ),
859880 sort : list [str ] = Query (None , alias = "sort" ),
860- where : Json = Query (None , alias = "where" ),
881+ where : Json = Query (None , alias = "where" , include_in_schema = False ),
861882 ):
862883 origin_record : CruddyModel | None = await repository .get_by_id (
863884 id = id , request = request
@@ -987,6 +1008,7 @@ def _ControllerConfigManyToMany(
9871008 policies_get_one ,
9881009 config .foreign_resource .policies ["get_many" ],
9891010 ),
1011+ openapi_extra = OPENAPI_WHERE_OVERRIDE ,
9901012 )
9911013 async def get_many_to_many (
9921014 request : Request ,
@@ -995,7 +1017,7 @@ async def get_many_to_many(
9951017 limit : int = default_limit ,
9961018 columns : list [str ] = Query (None , alias = "columns" ),
9971019 sort : list [str ] = Query (None , alias = "sort" ),
998- where : Json = Query (None , alias = "where" ),
1020+ where : Json = Query (None , alias = "where" , include_in_schema = False ),
9991021 ):
10001022 # Consider raising 404 here and in get by ID
10011023 if await repository .get_by_id (id = id , request = request ) == None :
@@ -1123,6 +1145,7 @@ def ControllerConfigurator(
11231145 response_model = single_schema ,
11241146 response_model_exclude_none = True ,
11251147 dependencies = assemble_policies (policies_universal , policies_get_one ),
1148+ openapi_extra = OPENAPI_WHERE_OVERRIDE ,
11261149 )(actions .get_by_id )
11271150
11281151 if not disable_get_many :
@@ -1132,6 +1155,7 @@ def ControllerConfigurator(
11321155 response_model = many_schema ,
11331156 response_model_exclude_none = True ,
11341157 dependencies = assemble_policies (policies_universal , policies_get_many ),
1158+ openapi_extra = OPENAPI_WHERE_OVERRIDE ,
11351159 )(actions .get_all )
11361160
11371161 # Add relationship link endpoints starting here...
0 commit comments