-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FilterExtensionGetRequest invalid fields #713
Comments
I think we should change it to a pydantic class. @vincentsarago what do you think? |
well I think attrs is used specifically for GET request, I don't really know why we use attr for GET and pydantic for POST but there might be a good reason. |
I was wondering if attr is used for GET requests so we can use converter? ex.
|
Clearly there might be another reason ... |
This makes total sense to me. I tried modifying |
Clearly we can't use |
what if we move all the class to pydantic ? |
We could fix the attrs class like this @attr.s
class FilterExtensionGetRequest(APIRequest):
"""Filter extension GET request model."""
filter: Optional[str] = attr.ib(default=None)
filter_crs: Optional[str] = attr.ib(default=None)
filter_lang: Optional[FilterLang] = attr.ib(default="cql2-text")
FilterExtensionGetRequest()
#FilterExtensionGetRequest(filter=None, filter_crs=None, filter_lang='cql2-text') This would require the implementations to look for the |
Yeah that's the other option I guess. I'm not sure how large of a change is required for that |
good thing that we are still in let me have a Quick Look |
ok I think I have a better understanding now. For the GET request, we can't use pydantic model (which can be used only for POST request, as body parameter). In order to define GET query parameter we can either use simple class, dataclass or attr. with Attr we can't use pydantic.Field or fastapi.Query, but we need to use in #714 I've replaced attr with python's BUT this adds some edge case issue where we have to Maybe we should just relaxe the SPEC and allow both asked in opengeospatial/ogcapi-common#224 to see what's the OGC pov |
well it seems that |
Ah, that's a bummer. Thank you for the detailed answer! How should we proceed here? |
@jamesfisher-gis I think moving to dataclass as proposed in #714 is the only solution |
https://github.com/stac-utils/stac-fastapi/blob/main/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/request.py#L13-L20
The
filter_crs
andfilter_lang
fields are invalid becauseFilterExtensionGetRequest
is anattrs
class, but it usesField
from pydantic.If I try to init the class and define
filter_lang
, for example.the class also does not impose the default values for
filter_crs
andfilter_lang
I think there are two options:
filter_crs
andfilter_lang
intoattrs
fields. AFAIKattrs
does not support applying an alias to fields.FilterExtensionGetRequest
into a pydantic class.Why do we have GET request models as
attrs
classes and POST request models aspydantic
classes?The text was updated successfully, but these errors were encountered: