Comments (14)
I'm not sure how large of a change is required for that
good thing that we are still in alpha
😄
let me have a Quick Look
from stac-fastapi.
I think we should change it to a pydantic class. @vincentsarago what do you think?
from stac-fastapi.
I was wondering if attr is used for GET requests so we can use converter? ex.
@attr.s
class FieldsExtensionGetRequest(APIRequest):
"""Additional fields for the GET request."""
fields: Optional[str] = attr.ib(default=None, converter=str2list)
from stac-fastapi.
I was wondering if attr is used for GET requests so we can use converter? ex.
@attr.s class FieldsExtensionGetRequest(APIRequest): """Additional fields for the GET request.""" fields: Optional[str] = attr.ib(default=None, converter=str2list)
This makes total sense to me.
I tried modifying FieldsExtensionGetRequest
to be a pydantic class, but this causes mixed model type errors since the other GET models are attrs classes.
from stac-fastapi.
Clearly we can't use Field
with the the filter extension GET like you said before.
from stac-fastapi.
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 attr.ib
to define the parameters. Sadly attr doesn't allow -
in alias name (maybe this should be raised in attr repo, but looking at how attr works, I'm not sure this will be resolved).
in #714 I've replaced attr with python's dataclass
. This allow the use of fastapi.Query and resolve the original issue.
BUT this adds some edge case issue where we have to order
the class we merge (base class + extension) to make sure the required
parameter are not placed after optional parameters. This is working for now but if one introduce an extension with a required parameter, then the code will not work!
Maybe we should just relaxe the SPEC and allow both filter-crs
and filter_crs
asked in opengeospatial/ogcapi-common#224 to see what's the OGC pov
from stac-fastapi.
well it seems that -
hyphen is a requirement, so we HAVE to comply to it
from stac-fastapi.
@jamesfisher-gis I think moving to dataclass as proposed in #714 is the only solution
from stac-fastapi.
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.
from stac-fastapi.
Clearly there might be another reason ...
from stac-fastapi.
I tried modifying FieldsExtensionGetRequest to be a pydantic class, but this causes mixed model type errors since the other GET models are attrs classes.
what if we move all the class to pydantic ?
from stac-fastapi.
Clearly we can't use
Field
with the the filter extension GET like you said before.
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 filter-crs
and filter-lang
params in the request and update if they don't match the default. Looks like that is what they are doing anyway.
from stac-fastapi.
I tried modifying FieldsExtensionGetRequest to be a pydantic class, but this causes mixed model type errors since the other GET models are attrs classes.
what if we move all the class to pydantic ?
Yeah that's the other option I guess. I'm not sure how large of a change is required for that
from stac-fastapi.
Ah, that's a bummer. Thank you for the detailed answer!
How should we proceed here?
from stac-fastapi.
Related Issues (20)
- pin sub-modules (api/extensions) to specific version HOT 4
- Detect disabled extensions in requests HOT 2
- types in `BaseSearchGetRequest`?
- How to tell if search is for single datetime? (Should `str_to_interval` return a single value for that?) HOT 7
- Remove pystac HOT 1
- Authentication and authorization implementation HOT 2
- Ensure Optional `query` Field Defaults to None for Pydantic V2 Compatibility
- move `filter extension` related code out of `types` submodule
- remove FieldsExtension dependency in `stac-fastapi.api` HOT 3
- Filter extension POST request model defaults to cql-json HOT 3
- Remove dependency between Aggregate and Filter extensions HOT 2
- Middleware Stack Rebuilt on Each StacApi Initialization HOT 4
- Custom RequestValidationError Handling Overwritten in stac-fastapi HOT 1
- Invalid RFC3339 datetime HOT 2
- `make_dataclass` erase the `__post_init__` method
- /collections/{collection_id}/items Token Pagination broken in 3.0.0b1, 3.0.0b2 HOT 3
- GET APIRequest attributes and converters HOT 1
- `ApiSettings.api_extension_is_enabled` method doesn't exist! HOT 1
- Adding CORSMiddleware HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stac-fastapi.