Skip to content

Commit 3400993

Browse files
committed
Update pydantic syntax to v2
1 parent 78218f7 commit 3400993

14 files changed

+350
-351
lines changed

Dockerfile

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Copyright (c) 2020 Tom Kralidis
99
# Copyright (c) 2019 Just van den Broecke
10-
# Copyright (c) 2020 Francesco Bartoli
10+
# Copyright (c) 2025 Francesco Bartoli
1111
# Copyright (c) 2024 Angelos Tzotsos
1212
# Copyright (c) 2023 Bernhard Mallinger
1313
#
@@ -134,12 +134,11 @@ RUN python3 -m pip install --no-cache-dir -r requirements-docker.txt \
134134
ADD . /pygeoapi
135135

136136
# Install pygeoapi
137-
RUN python3 -m pip install --no-cache-dir -e .
137+
RUN python3 -m pip install --no-cache-dir -e .
138138

139-
RUN \
139+
RUN \
140140
# Set default config and entrypoint for Docker Image
141141
cp /pygeoapi/docker/default.config.yml /pygeoapi/local.config.yml \
142-
&& cp /pygeoapi/docker/entrypoint.sh /entrypoint.sh
142+
&& cp /pygeoapi/docker/entrypoint.sh /entrypoint.sh
143143

144144
ENTRYPOINT ["/entrypoint.sh"]
145-

docker/default.config.yml

+18-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2019 Just van den Broecke
88
# Copyright (c) 2020 Tom Kralidis
9-
# Copyright (c) 2020 Francesco Bartoli
9+
# Copyright (c) 2025 Francesco Bartoli
1010
#
1111
# Permission is hereby granted, free of charge, to any person
1212
# obtaining a copy of this software and associated documentation
@@ -218,18 +218,18 @@ resources:
218218
# target_srs: EPSG:4326
219219
source_capabilities:
220220
paging: True
221-
221+
222222
source_options:
223223
# OGR_WFS_VERSION: 1.1.0
224224
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO
225-
225+
226226
gdal_ogr_options:
227227
EMPTY_AS_NULL: NO
228228
GDAL_CACHEMAX: 64
229229
# GDAL_HTTP_PROXY: (optional proxy)
230230
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
231231
CPL_DEBUG: NO
232-
232+
233233
crs:
234234
- http://www.opengis.net/def/crs/EPSG/0/4258
235235
- http://www.opengis.net/def/crs/EPSG/0/28992
@@ -269,18 +269,18 @@ resources:
269269
# target_srs: EPSG:4326
270270
source_capabilities:
271271
paging: True
272-
272+
273273
source_options:
274274
# OGR_WFS_VERSION: 2.0.0
275275
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO
276-
276+
277277
gdal_ogr_options:
278278
EMPTY_AS_NULL: NO
279279
GDAL_CACHEMAX: 64
280280
# GDAL_HTTP_PROXY: (optional proxy)
281281
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
282282
CPL_DEBUG: NO
283-
283+
284284
crs:
285285
- http://www.opengis.net/def/crs/EPSG/0/4258
286286
- http://www.opengis.net/def/crs/EPSG/0/26912
@@ -319,18 +319,18 @@ resources:
319319
# target_srs: EPSG:4326
320320
source_capabilities:
321321
paging: True
322-
322+
323323
source_options:
324324
# OGR_WFS_VERSION: 1.1.0
325325
OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN: NO
326-
326+
327327
gdal_ogr_options:
328328
EMPTY_AS_NULL: NO
329329
GDAL_CACHEMAX: 64
330330
# GDAL_HTTP_PROXY: (optional proxy)
331331
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
332332
CPL_DEBUG: NO
333-
333+
334334
crs:
335335
- http://www.opengis.net/def/crs/EPSG/0/4258
336336
- http://www.opengis.net/def/crs/EPSG/0/32632
@@ -374,14 +374,14 @@ resources:
374374
# target_srs: EPSG:4326
375375
source_capabilities:
376376
paging: True
377-
377+
378378
gdal_ogr_options:
379379
EMPTY_AS_NULL: NO
380380
GDAL_CACHEMAX: 64
381381
# GDAL_HTTP_PROXY: (optional proxy)
382382
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
383383
CPL_DEBUG: NO
384-
384+
385385
id_field: osm_id
386386
layer: poi_portugal
387387

@@ -414,14 +414,14 @@ resources:
414414
# target_srs: EPSG:4326
415415
source_capabilities:
416416
paging: True
417-
417+
418418
gdal_ogr_options:
419419
EMPTY_AS_NULL: NO
420420
GDAL_CACHEMAX: 64
421421
# GDAL_HTTP_PROXY: (optional proxy)
422422
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
423423
CPL_DEBUG: NO
424-
424+
425425
id_field: id
426426
layer: ne_110m_lakes
427427

@@ -457,14 +457,14 @@ resources:
457457
# target_srs: EPSG:4326
458458
source_capabilities:
459459
paging: True
460-
460+
461461
gdal_ogr_options:
462462
EMPTY_AS_NULL: NO
463463
GDAL_CACHEMAX: 64
464464
# GDAL_HTTP_PROXY: (optional proxy)
465465
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
466466
CPL_DEBUG: NO
467-
467+
468468
id_field: id
469469
layer: ogrgeojson
470470

@@ -499,14 +499,14 @@ resources:
499499
# target_srs: EPSG:4326
500500
source_capabilities:
501501
paging: True
502-
502+
503503
gdal_ogr_options:
504504
EMPTY_AS_NULL: NO
505505
GDAL_CACHEMAX: 64
506506
# GDAL_HTTP_PROXY: (optional proxy)
507507
# GDAL_PROXY_AUTH: (optional auth for remote WFS)
508508
CPL_DEBUG: NO
509-
509+
510510
id_field: id
511511
layer: OGRGeoJSON
512512

pygeoapi/models/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Authors: Francesco Bartoli <xbartolone@gmail.com>
44
#
5-
# Copyright (c) 2021 Francesco Bartoli
5+
# Copyright (c) 2025 Francesco Bartoli
66
#
77
# Permission is hereby granted, free of charge, to any person
88
# obtaining a copy of this software and associated documentation

pygeoapi/models/config.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Francesco Bartoli <xbartolone@gmail.com>
77
#
88
# Copyright (c) 2023 Sander Schaminee
9-
# Copyright (c) 2024 Francesco Bartoli
9+
# Copyright (c) 2025 Francesco Bartoli
1010
#
1111
# Permission is hereby granted, free of charge, to any person
1212
# obtaining a copy of this software and associated documentation
@@ -36,7 +36,7 @@
3636

3737
class APIRules(BaseModel):
3838
""" Pydantic model for API design rules that must be adhered to. """
39-
api_version: str = Field(regex=r'^\d+\.\d+\..+$',
39+
api_version: str = Field(pattern=r'^\d+\.\d+\..+$',
4040
description="Semantic API version number.")
4141
url_prefix: str = Field(
4242
"",
@@ -62,11 +62,11 @@ def create(**rules_config) -> 'APIRules':
6262
""" Returns a new APIRules instance for the current API version
6363
and configured rules. """
6464
obj = {
65-
k: v for k, v in rules_config.items() if k in APIRules.__fields__
65+
k: v for k, v in rules_config.items() if k in APIRules.model_fields
6666
}
6767
# Validation will fail if required `api_version` is missing
6868
# or if `api_version` is not a semantic version number
69-
return APIRules.parse_obj(obj)
69+
return APIRules.model_validate(obj)
7070

7171
@property
7272
def response_headers(self) -> dict:

pygeoapi/models/openapi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Authors: Francesco Bartoli <xbartolone@gmail.com>
66
#
7-
# Copyright (c) 2024 Francesco Bartoli
7+
# Copyright (c) 2025 Francesco Bartoli
88
#
99
# Permission is hereby granted, free of charge, to any person
1010
# obtaining a copy of this software and associated documentation
@@ -40,4 +40,4 @@ class SupportedFormats(Enum):
4040

4141

4242
class OAPIFormat(BaseModel):
43-
__root__: SupportedFormats = SupportedFormats.YAML
43+
root: SupportedFormats = SupportedFormats.YAML

0 commit comments

Comments
 (0)