Skip to content

Commit 402d783

Browse files
committed
Fix: Pass OpenAPI schema data to all property types
1 parent 5fcaf72 commit 402d783

File tree

16 files changed

+53
-0
lines changed

16 files changed

+53
-0
lines changed

openapi_python_client/parser/properties/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def _string_based_property(
6464
python_name=python_name,
6565
description=data.description,
6666
example=data.example,
67+
data=data,
6768
)
6869
if string_format == "date":
6970
return DateProperty.build(
@@ -73,6 +74,7 @@ def _string_based_property(
7374
python_name=python_name,
7475
description=data.description,
7576
example=data.example,
77+
data=data,
7678
)
7779
if string_format == "binary":
7880
return FileProperty.build(
@@ -82,6 +84,7 @@ def _string_based_property(
8284
python_name=python_name,
8385
description=data.description,
8486
example=data.example,
87+
data=data,
8588
)
8689
if string_format == "uuid":
8790
return UuidProperty.build(
@@ -91,6 +94,7 @@ def _string_based_property(
9194
python_name=python_name,
9295
description=data.description,
9396
example=data.example,
97+
data=data,
9498
)
9599
return StringProperty.build(
96100
name=name,
@@ -99,6 +103,7 @@ def _string_based_property(
99103
python_name=python_name,
100104
description=data.description,
101105
example=data.example,
106+
data=data,
102107
)
103108

104109

@@ -193,6 +198,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
193198
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
194199
description=data.description,
195200
example=data.example,
201+
data=data,
196202
),
197203
schemas,
198204
)
@@ -232,6 +238,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
232238
const=data.const,
233239
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
234240
description=data.description,
241+
data=data,
235242
),
236243
schemas,
237244
)
@@ -249,6 +256,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
249256
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
250257
description=data.description,
251258
example=data.example,
259+
data=data,
252260
),
253261
schemas,
254262
)
@@ -261,6 +269,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
261269
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
262270
description=data.description,
263271
example=data.example,
272+
data=data,
264273
),
265274
schemas,
266275
)
@@ -273,6 +282,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
273282
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
274283
description=data.description,
275284
example=data.example,
285+
data=data,
276286
),
277287
schemas,
278288
)

openapi_python_client/parser/properties/any.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from attr import define
66

77
from ...utils import PythonIdentifier
8+
from ... import schema as oai
89
from .protocol import PropertyProtocol, Value
910

1011

openapi_python_client/parser/properties/boolean.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class BooleanProperty(PropertyProtocol):
2020
python_name: PythonIdentifier
2121
description: str | None
2222
example: str | None
23+
data: oai.Schema
2324

2425
_type_string: ClassVar[str] = "bool"
2526
_json_type_string: ClassVar[str] = "bool"
@@ -40,6 +41,7 @@ def build(
4041
python_name: PythonIdentifier,
4142
description: str | None,
4243
example: str | None,
44+
data: oai.Schema,
4345
) -> BooleanProperty | PropertyError:
4446
checked_default = cls.convert_value(default)
4547
if isinstance(checked_default, PropertyError):
@@ -51,6 +53,7 @@ def build(
5153
python_name=python_name,
5254
description=description,
5355
example=example,
56+
data=data,
5457
)
5558

5659
@classmethod

openapi_python_client/parser/properties/const.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from attr import define
66

77
from ...utils import PythonIdentifier
8+
from ... import schema as oai
89
from ..errors import PropertyError
910
from .protocol import PropertyProtocol, Value
1011
from .string import StringProperty
@@ -21,6 +22,7 @@ class ConstProperty(PropertyProtocol):
2122
python_name: PythonIdentifier
2223
description: str | None
2324
example: None
25+
data: oai.Schema
2426
template: ClassVar[str] = "const_property.py.jinja"
2527

2628
@classmethod
@@ -33,6 +35,7 @@ def build(
3335
python_name: PythonIdentifier,
3436
required: bool,
3537
description: str | None,
38+
data: oai.Schema,
3639
) -> ConstProperty | PropertyError:
3740
"""
3841
Create a `ConstProperty` the right way.
@@ -55,6 +58,7 @@ def build(
5558
default=None,
5659
description=description,
5760
example=None,
61+
data=data,
5862
)
5963
converted_default = prop.convert_value(default)
6064
if isinstance(converted_default, PropertyError):

openapi_python_client/parser/properties/date.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from dateutil.parser import isoparse
77

88
from ...utils import PythonIdentifier
9+
from ... import schema as oai
910
from ..errors import PropertyError
1011
from .protocol import PropertyProtocol, Value
1112

@@ -20,6 +21,7 @@ class DateProperty(PropertyProtocol):
2021
python_name: PythonIdentifier
2122
description: str | None
2223
example: str | None
24+
data: oai.Schema
2325

2426
_type_string: ClassVar[str] = "datetime.date"
2527
_json_type_string: ClassVar[str] = "str"
@@ -34,6 +36,7 @@ def build(
3436
python_name: PythonIdentifier,
3537
description: str | None,
3638
example: str | None,
39+
data: oai.Schema
3740
) -> DateProperty | PropertyError:
3841
checked_default = cls.convert_value(default)
3942
if isinstance(checked_default, PropertyError):
@@ -46,6 +49,7 @@ def build(
4649
python_name=python_name,
4750
description=description,
4851
example=example,
52+
data=data,
4953
)
5054

5155
@classmethod

openapi_python_client/parser/properties/datetime.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from dateutil.parser import isoparse
77

88
from ...utils import PythonIdentifier
9+
from ... import schema as oai
910
from ..errors import PropertyError
1011
from .protocol import PropertyProtocol, Value
1112

@@ -22,6 +23,7 @@ class DateTimeProperty(PropertyProtocol):
2223
python_name: PythonIdentifier
2324
description: str | None
2425
example: str | None
26+
data: oai.Schema
2527

2628
_type_string: ClassVar[str] = "datetime.datetime"
2729
_json_type_string: ClassVar[str] = "str"
@@ -36,6 +38,7 @@ def build(
3638
python_name: PythonIdentifier,
3739
description: str | None,
3840
example: str | None,
41+
data: oai.Schema,
3942
) -> DateTimeProperty | PropertyError:
4043
checked_default = cls.convert_value(default)
4144
if isinstance(checked_default, PropertyError):
@@ -48,6 +51,7 @@ def build(
4851
python_name=python_name,
4952
description=description,
5053
example=example,
54+
data=data,
5155
)
5256

5357
@classmethod

openapi_python_client/parser/properties/enum_property.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class EnumProperty(PropertyProtocol):
2929
python_name: utils.PythonIdentifier
3030
description: str | None
3131
example: str | None
32+
data: oai.Schema
3233
values: dict[str, ValueType]
3334
class_info: Class
3435
value_type: type[ValueType]
@@ -142,6 +143,7 @@ def build( # noqa: PLR0911
142143
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
143144
description=data.description,
144145
example=data.example,
146+
data=data,
145147
)
146148
checked_default = prop.convert_value(data.default)
147149
if isinstance(checked_default, PropertyError):

openapi_python_client/parser/properties/file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from attr import define
66

77
from ...utils import PythonIdentifier
8+
from ... import schema as oai
89
from ..errors import PropertyError
910
from .protocol import PropertyProtocol
1011

@@ -19,6 +20,7 @@ class FileProperty(PropertyProtocol):
1920
python_name: PythonIdentifier
2021
description: str | None
2122
example: str | None
23+
data: oai.Schema
2224

2325
_type_string: ClassVar[str] = "File"
2426
# Return type of File.to_tuple()
@@ -34,6 +36,7 @@ def build(
3436
python_name: PythonIdentifier,
3537
description: str | None,
3638
example: str | None,
39+
data: oai.Schema,
3740
) -> FileProperty | PropertyError:
3841
default_or_err = cls.convert_value(default)
3942
if isinstance(default_or_err, PropertyError):
@@ -46,6 +49,7 @@ def build(
4649
python_name=python_name,
4750
description=description,
4851
example=example,
52+
data=data,
4953
)
5054

5155
@classmethod

openapi_python_client/parser/properties/float.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class FloatProperty(PropertyProtocol):
2020
python_name: PythonIdentifier
2121
description: str | None
2222
example: str | None
23+
data: oai.Schema
2324

2425
_type_string: ClassVar[str] = "float"
2526
_json_type_string: ClassVar[str] = "float"
@@ -40,6 +41,7 @@ def build(
4041
python_name: PythonIdentifier,
4142
description: str | None,
4243
example: str | None,
44+
data: oai.Schema,
4345
) -> FloatProperty | PropertyError:
4446
checked_default = cls.convert_value(default)
4547
if isinstance(checked_default, PropertyError):
@@ -52,6 +54,7 @@ def build(
5254
python_name=python_name,
5355
description=description,
5456
example=example,
57+
data=data,
5558
)
5659

5760
@classmethod

openapi_python_client/parser/properties/int.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class IntProperty(PropertyProtocol):
2020
python_name: PythonIdentifier
2121
description: str | None
2222
example: str | None
23+
data: oai.Schema
2324

2425
_type_string: ClassVar[str] = "int"
2526
_json_type_string: ClassVar[str] = "int"
@@ -40,6 +41,7 @@ def build(
4041
python_name: PythonIdentifier,
4142
description: str | None,
4243
example: str | None,
44+
data: oai.Schema,
4345
) -> IntProperty | PropertyError:
4446
checked_default = cls.convert_value(default)
4547
if isinstance(checked_default, PropertyError):
@@ -52,6 +54,7 @@ def build(
5254
python_name=python_name,
5355
description=description,
5456
example=example,
57+
data=data,
5558
)
5659

5760
@classmethod

0 commit comments

Comments
 (0)