Skip to content
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

update to pydantic 2 #625

Merged
merged 44 commits into from
Apr 26, 2024
Merged
Changes from 2 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
013caee
update to pydantic 2
thomas-maschler Feb 10, 2024
669587e
update changelog
thomas-maschler Feb 10, 2024
a168498
typo
thomas-maschler Feb 10, 2024
cd9f75e
add CI for Python 3.12
thomas-maschler Feb 10, 2024
781c46e
drop support for python 3.8
thomas-maschler Feb 10, 2024
ce7f6e8
update python version for docs
thomas-maschler Feb 10, 2024
19cce99
update python for docs docker container
thomas-maschler Feb 10, 2024
36044d6
update python version in dockerfile
thomas-maschler Feb 10, 2024
9210501
handle post requests
thomas-maschler Feb 12, 2024
1fa87b7
test wrapper
thomas-maschler Feb 12, 2024
653f3a6
pass through StacBaseModel
thomas-maschler Feb 12, 2024
6727568
keep py38
thomas-maschler Feb 20, 2024
e01e95a
change install order
thomas-maschler Feb 20, 2024
db5cfb6
lint
thomas-maschler Feb 20, 2024
02f2702
revert back to >=3.8 in setup.py
thomas-maschler Feb 20, 2024
8118f10
add switch to use either TypeDict or StacPydantic Response
thomas-maschler Feb 23, 2024
b52f216
lint and format with ruff
thomas-maschler Feb 23, 2024
0f7d8c9
Merge branch 'main' into pydantic2
thomas-maschler Feb 23, 2024
f2f9374
remove comment
thomas-maschler Feb 23, 2024
273f819
update change log
thomas-maschler Feb 23, 2024
dc67a4d
use Optional not | None
thomas-maschler Feb 24, 2024
7208dd7
use Optional not | None
thomas-maschler Feb 24, 2024
e24351a
update dependencies
thomas-maschler Apr 4, 2024
5bdd615
hard code versions and address other comments
thomas-maschler Apr 4, 2024
eea9c82
remove response_model module, update openapi schema
thomas-maschler Apr 5, 2024
d0762eb
add responses to transactions
thomas-maschler Apr 5, 2024
9d9ab57
do not wrap response into response_class
vincentsarago Apr 5, 2024
68aff85
Merge pull request #2 from vincentsarago/patch/avoid-wrapping-response
thomas-maschler Apr 5, 2024
3d946f6
fix tests
thomas-maschler Apr 5, 2024
c9e6f0d
update changelog, remove redundant variable
thomas-maschler Apr 5, 2024
1652232
update from main
vincentsarago Apr 9, 2024
aa1ab5e
lint bench
vincentsarago Apr 9, 2024
8ad9f97
reorder installs
vincentsarago Apr 9, 2024
bf01ad9
do not push benchmark if not in stac-utils/stac-fastapi repo
vincentsarago Apr 9, 2024
6b0949a
Add text about response validation to readme.
thomas-maschler Apr 10, 2024
9b14b04
merge main
thomas-maschler Apr 10, 2024
6f1b478
fix warning
thomas-maschler Apr 24, 2024
0bb2019
merge main
thomas-maschler Apr 24, 2024
6d943aa
update from main
vincentsarago Apr 26, 2024
d46d287
remove versions
vincentsarago Apr 26, 2024
641614a
fix
vincentsarago Apr 26, 2024
3b50a6d
Update README.md
jonhealy1 Apr 26, 2024
37594ec
update changelog
vincentsarago Apr 26, 2024
83d19f8
Merge branch 'pydantic2' of https://github.com/thomas-maschler/stac-f…
vincentsarago Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -46,9 +46,9 @@ Backends are hosted in their own repositories:

A common question when using this package is how request and response types are validated?

This package uses [`stack-pydantic`](https://github.com/stac-utils/stac-pydantic) to validate and document STAC objects. However, by default, validation of response types is turned off and the API will simply forward responses without validating them against the Pydantic model first. This decision was made with the assumption that responses usually come from a (typed) database and can be considered save. Extra validation would only increase latency, in particular for large payloads.
This package uses [`stac-pydantic`](https://github.com/stac-utils/stac-pydantic) to validate and document STAC objects. However, by default, validation of response types is turned off and the API will simply forward responses without validating them against the Pydantic model first. This decision was made with the assumption that responses usually come from a (typed) database and can be considered safe. Extra validation would only increase latency, in particular for large payloads.

To turn on response validation, set `ENABLE_RESPONSE_MODELS` to `True`. Either as environment variable or directly in the `ApiSettings`.
To turn on response validation, set `ENABLE_RESPONSE_MODELS` to `True`. Either as an environment variable or directly in the `ApiSettings`.

With the introduction of Pydantic 2, the extra [time it takes to validate models became negatable](https://github.com/stac-utils/stac-fastapi/pull/625#issuecomment-2045824578). While `ENABLE_RESPONSE_MODELS` still defaults to `False` there should be no penalty for users to turn on this feature but users discretion is advised.