Skip to content

Commit e69a974

Browse files
authored
Revert pydantic models to v1 version (#1584)
* Revert pydantic models to v1 version Revert pydantic models to v1 version Revert pydantic models to v1 version Revert pydantic models to v1 version * Add initial tests for models Add initial tests for models * Revert pydantic models to v1 version Revert pydantic models to v1 version Revert pydantic models to v1 version Revert pydantic models to v1 version * Add initial tests for models Add initial tests for models * Fix and replace methods from pydantic v2 * Add more tests for cql models
1 parent 5468896 commit e69a974

11 files changed

+284
-175
lines changed

Diff for: pygeoapi/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Francesco Bartoli <[email protected]>
55
#
66
# Copyright (c) 2022 Tom Kralidis
7-
# Copyright (c) 2023 Francesco Bartoli
7+
# Copyright (c) 2024 Francesco Bartoli
88
#
99
# Permission is hereby granted, free of charge, to any person
1010
# obtaining a copy of this software and associated documentation

Diff for: pygeoapi/models/config.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# =================================================================
44
#
55
# Authors: Sander Schaminee <[email protected]>
6+
# Francesco Bartoli <[email protected]>
67
#
78
# Copyright (c) 2023 Sander Schaminee
9+
# Copyright (c) 2024 Francesco Bartoli
810
#
911
# Permission is hereby granted, free of charge, to any person
1012
# obtaining a copy of this software and associated documentation
@@ -34,7 +36,7 @@
3436

3537
class APIRules(BaseModel):
3638
""" Pydantic model for API design rules that must be adhered to. """
37-
api_version: str = Field(pattern=r'^\d+\.\d+\..+$',
39+
api_version: str = Field(regex=r'^\d+\.\d+\..+$',
3840
description="Semantic API version number.")
3941
url_prefix: str = Field(
4042
"",
@@ -60,11 +62,11 @@ def create(**rules_config) -> 'APIRules':
6062
""" Returns a new APIRules instance for the current API version
6163
and configured rules. """
6264
obj = {
63-
k: v for k, v in rules_config.items() if k in APIRules.model_fields
65+
k: v for k, v in rules_config.items() if k in APIRules.__fields__
6466
}
6567
# Validation will fail if required `api_version` is missing
6668
# or if `api_version` is not a semantic version number
67-
return APIRules.model_validate(obj)
69+
return APIRules.parse_obj(obj)
6870

6971
@property
7072
def response_headers(self) -> dict:

0 commit comments

Comments
 (0)