Closed lu-pl closed 1 hour ago
Note: rdfproxy.QueryParameters
must be publicly available because non-FastAPI code will have to manually instantiate QueryParameters
, which btw is a good thing. :)
Having query parameters live in their own namespace is also convenient, e.g. SPARQLModelAdapter.query
would return a Page
object like so:
return Page(
items=items,
page=query_parameters.page,
size=query_parameters.size,
total=total,
pages=pages,
)
Using a Query Parameter model for
SPARQLModelAdapter.query
parameters provides better OpenAPI/Swagger definitions for FastAPI code, is generally more explicit and allows for early runtime validation of query parameters.Passing a single
QueryParameters
instance toSPARQLModelAdapter.query
is much more convenient and less error-prone than requiring all route parameter kwargs to be passed manually. Also, this makes introducing additional parameters forSPARQLModelAdapter.query
(e.g. filtering and ordering) easy and defines a single interface for extensions.