Skip to content

Commit 18a236e

Browse files
committed
Revert "fix(deps): downgrade to Pydantic v1 to support Pyodide WASM execution"
This reverts commit 8f52582.
1 parent 8f52582 commit 18a236e

7 files changed

Lines changed: 149 additions & 55 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "OpenAPI 3.2.0 Python Client"
99
readme = "README.md"
1010
requires-python = ">=3.9,<3.14"
1111
dependencies = [
12-
"pydantic<2.0",
12+
"pydantic>=2.0",
1313
"libcst",
1414
"urllib3",
1515
"python-cdd>=0.0.98",

‎src/openapi_client/classes/emit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def emit_class(name: str, schema: Schema) -> cst.ClassDef:
2020
if getattr(schema, "properties", None):
2121
for prop_name, prop_schema in schema.properties.items(): # type: ignore[union-attr]
2222
if isinstance(prop_schema, Reference):
23-
prop_type = "Any" # Simplification for Reference # pragma: no cover
23+
prop_type = "Any" # Simplification for Reference
2424
else:
2525
prop_type = "Any"
2626
if getattr(prop_schema, "type", None) == "string":

‎src/openapi_client/cli.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def scaffold_package(out_dir: Path):
154154
name = "generated-client"
155155
version = "0.0.1"
156156
dependencies = [
157-
"pydantic<2.0",
157+
"pydantic>=2.0",
158158
"urllib3",
159159
]
160160
""",

‎src/openapi_client/models.py‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
from __future__ import annotations
44

55
from typing import Any, Dict, List, Optional, Union
6-
from pydantic import BaseModel, Field, Extra
6+
from pydantic import BaseModel, ConfigDict, Field
77

88

99
class OpenAPIBase(BaseModel):
1010
"""OpenAPI OpenAPIBase model."""
1111

12-
class Config:
13-
"""Pydantic config."""
14-
extra = "allow"
15-
allow_population_by_field_name = True
12+
model_config = ConfigDict(
13+
extra="allow",
14+
populate_by_name=True,
15+
)
1616

1717

1818
class Contact(OpenAPIBase):
@@ -346,5 +346,11 @@ class OpenAPI(OpenAPIBase):
346346
# Rebuild models due to forward references
347347
for model in list(locals().values()):
348348
if isinstance(model, type) and issubclass(model, BaseModel) and model != BaseModel:
349-
if hasattr(model, "update_forward_refs"):
350-
model.update_forward_refs()
349+
if hasattr(model, "model_rebuild"):
350+
try:
351+
model.model_rebuild()
352+
except AttributeError: # pragma: no cover
353+
if hasattr(model, "update_forward_refs"): # pragma: no cover
354+
model.update_forward_refs() # pragma: no cover
355+
elif hasattr(model, "update_forward_refs"): # pragma: no cover
356+
model.update_forward_refs() # pragma: no cover

‎src/openapi_client/openapi/emit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def emit_openapi_dict(spec: OpenAPI) -> Dict[str, Any]:
1212
"""Emit an OpenAPI model as a dictionary."""
13-
return spec.dict(by_alias=True, exclude_none=True)
13+
return spec.model_dump(by_alias=True, exclude_none=True)
1414

1515

1616
def emit_openapi_json(spec: OpenAPI, indent: int = 2) -> str:

‎tests/test_coverage_emit_ref.py‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎uv.lock‎

Lines changed: 132 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)