Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions openapi_python_client/parser/properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _string_based_property(
python_name=python_name,
description=data.description,
example=data.example,
data=data,
)
if string_format == "date":
return DateProperty.build(
Expand All @@ -73,6 +74,7 @@ def _string_based_property(
python_name=python_name,
description=data.description,
example=data.example,
data=data,
)
if string_format == "binary":
return FileProperty.build(
Expand All @@ -82,6 +84,7 @@ def _string_based_property(
python_name=python_name,
description=data.description,
example=data.example,
data=data,
)
if string_format == "uuid":
return UuidProperty.build(
Expand All @@ -91,6 +94,7 @@ def _string_based_property(
python_name=python_name,
description=data.description,
example=data.example,
data=data,
)
return StringProperty.build(
name=name,
Expand All @@ -99,6 +103,7 @@ def _string_based_property(
python_name=python_name,
description=data.description,
example=data.example,
data=data,
)


Expand Down Expand Up @@ -193,6 +198,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
),
schemas,
)
Expand Down Expand Up @@ -232,6 +238,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
const=data.const,
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
data=data,
),
schemas,
)
Expand All @@ -249,6 +256,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
),
schemas,
)
Expand All @@ -261,6 +269,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
),
schemas,
)
Expand All @@ -273,6 +282,7 @@ def property_from_data( # noqa: PLR0911, PLR0912
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
),
schemas,
)
Expand Down
1 change: 1 addition & 0 deletions openapi_python_client/parser/properties/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from attr import define

from ...utils import PythonIdentifier
from ... import schema as oai
from .protocol import PropertyProtocol, Value


Expand Down
3 changes: 3 additions & 0 deletions openapi_python_client/parser/properties/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BooleanProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "bool"
_json_type_string: ClassVar[str] = "bool"
Expand All @@ -40,6 +41,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> BooleanProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -51,6 +53,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions openapi_python_client/parser/properties/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from attr import define

from ...utils import PythonIdentifier
from ... import schema as oai
from ..errors import PropertyError
from .protocol import PropertyProtocol, Value
from .string import StringProperty
Expand All @@ -21,6 +22,7 @@ class ConstProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: None
data: oai.Schema
template: ClassVar[str] = "const_property.py.jinja"

@classmethod
Expand All @@ -33,6 +35,7 @@ def build(
python_name: PythonIdentifier,
required: bool,
description: str | None,
data: oai.Schema,
) -> ConstProperty | PropertyError:
"""
Create a `ConstProperty` the right way.
Expand All @@ -55,6 +58,7 @@ def build(
default=None,
description=description,
example=None,
data=data,
)
converted_default = prop.convert_value(default)
if isinstance(converted_default, PropertyError):
Expand Down
4 changes: 4 additions & 0 deletions openapi_python_client/parser/properties/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dateutil.parser import isoparse

from ...utils import PythonIdentifier
from ... import schema as oai
from ..errors import PropertyError
from .protocol import PropertyProtocol, Value

Expand All @@ -20,6 +21,7 @@ class DateProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "datetime.date"
_json_type_string: ClassVar[str] = "str"
Expand All @@ -34,6 +36,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema
) -> DateProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -46,6 +49,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions openapi_python_client/parser/properties/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dateutil.parser import isoparse

from ...utils import PythonIdentifier
from ... import schema as oai
from ..errors import PropertyError
from .protocol import PropertyProtocol, Value

Expand All @@ -22,6 +23,7 @@ class DateTimeProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "datetime.datetime"
_json_type_string: ClassVar[str] = "str"
Expand All @@ -36,6 +38,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> DateTimeProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -48,6 +51,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions openapi_python_client/parser/properties/enum_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EnumProperty(PropertyProtocol):
python_name: utils.PythonIdentifier
description: str | None
example: str | None
data: oai.Schema
values: dict[str, ValueType]
class_info: Class
value_type: type[ValueType]
Expand Down Expand Up @@ -142,6 +143,7 @@ def build( # noqa: PLR0911
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
)
checked_default = prop.convert_value(data.default)
if isinstance(checked_default, PropertyError):
Expand Down
4 changes: 4 additions & 0 deletions openapi_python_client/parser/properties/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from attr import define

from ...utils import PythonIdentifier
from ... import schema as oai
from ..errors import PropertyError
from .protocol import PropertyProtocol

Expand All @@ -19,6 +20,7 @@ class FileProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "File"
# Return type of File.to_tuple()
Expand All @@ -34,6 +36,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> FileProperty | PropertyError:
default_or_err = cls.convert_value(default)
if isinstance(default_or_err, PropertyError):
Expand All @@ -46,6 +49,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions openapi_python_client/parser/properties/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FloatProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "float"
_json_type_string: ClassVar[str] = "float"
Expand All @@ -40,6 +41,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> FloatProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -52,6 +54,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions openapi_python_client/parser/properties/int.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IntProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_type_string: ClassVar[str] = "int"
_json_type_string: ClassVar[str] = "int"
Expand All @@ -40,6 +41,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> IntProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -52,6 +54,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions openapi_python_client/parser/properties/list_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ListProperty(PropertyProtocol):
python_name: utils.PythonIdentifier
description: str | None
example: str | None
data: oai.Schema
inner_property: PropertyProtocol
template: ClassVar[str] = "list_property.py.jinja"

Expand Down Expand Up @@ -98,6 +99,7 @@ def build(
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
),
schemas,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class LiteralEnumProperty(PropertyProtocol):
python_name: utils.PythonIdentifier
description: str | None
example: str | None
data: oai.Schema
values: set[ValueType]
class_info: Class
value_type: type[ValueType]
Expand Down Expand Up @@ -140,6 +141,7 @@ def build( # noqa: PLR0911
python_name=utils.PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
)
checked_default = prop.convert_value(data.default)
if isinstance(checked_default, PropertyError):
Expand Down
3 changes: 3 additions & 0 deletions openapi_python_client/parser/properties/none.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NoneProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema

_allowed_locations: ClassVar[set[oai.ParameterLocation]] = {
oai.ParameterLocation.QUERY,
Expand All @@ -38,6 +39,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema
) -> NoneProperty | PropertyError:
checked_default = cls.convert_value(default)
if isinstance(checked_default, PropertyError):
Expand All @@ -49,6 +51,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions openapi_python_client/parser/properties/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class StringProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema
_type_string: ClassVar[str] = "str"
_json_type_string: ClassVar[str] = "str"
_allowed_locations: ClassVar[set[oai.ParameterLocation]] = {
Expand All @@ -39,6 +40,7 @@ def build(
python_name: PythonIdentifier,
description: str | None,
example: str | None,
data: oai.Schema,
) -> StringProperty | PropertyError:
checked_default = cls.convert_value(default)
return cls(
Expand All @@ -48,6 +50,7 @@ def build(
python_name=python_name,
description=description,
example=example,
data=data,
)

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions openapi_python_client/parser/properties/union.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UnionProperty(PropertyProtocol):
python_name: PythonIdentifier
description: str | None
example: str | None
data: oai.Schema
inner_properties: list[PropertyProtocol]
template: ClassVar[str] = "union_property.py.jinja"

Expand Down Expand Up @@ -112,6 +113,7 @@ def flatten_union_properties(possibly_nested: list[PropertyProtocol]) -> Iterato
python_name=PythonIdentifier(value=name, prefix=config.field_prefix),
description=data.description,
example=data.example,
data=data,
)
default_or_error = prop.convert_value(data.default)
if isinstance(default_or_error, PropertyError):
Expand Down
Loading