Closed drnextgis closed 1 month ago
I believe you're correct -- I've opened https://github.com/stac-utils/stac-fastapi/pull/519 to track the issue. Currently I just have a failing test to demonstrate the issue.
I confirmed this.
The thing was that we are using wrap_response
to make sure the endpoints return a starlette Response, but this issue is then FastAPI will not run pydantic validation/serialization if the endpoint respond a Response object
I've changed this in https://github.com/thomas-maschler/stac-fastapi/pull/2 for next stac-fastapi major version and will also change this for ~2.4 (maybe 2.5) https://github.com/stac-utils/stac-fastapi/pull/650#issuecomment-2042798205
I believe this is not fixed and tested
I've got confused by the fact that response models are not being used to validate responses. Isn't that its main purpose? As you can see here for example response model is Collection. But if we modify collection's content in the database (pgstac) in order not to be align with the response model stac-fastapi simple ignores it and returns what we have in the database without any warning/error:
But according to the response model type should be
Collection
.ENABLE_RESPONSE_MODELS
set totrue