Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 46f6981

Browse files
committed
v3 updates format fn names (#199)
* Removes trailing underscores format functions * Samples regenerated
1 parent 61910c9 commit 46f6981

File tree

17 files changed

+68
-68
lines changed

17 files changed

+68
-68
lines changed

samples/client/3_0_3_unit_test/python/src/unit_test_api/schemas/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
immutabledict
5353
)
5454
from .format import (
55-
as_date_,
56-
as_datetime_,
57-
as_decimal_,
58-
as_uuid_
55+
as_date,
56+
as_datetime,
57+
as_decimal,
58+
as_uuid
5959
)
6060

6161
def typed_dict_to_instance(t_dict: typing_extensions._TypedDictMeta) -> typing.Mapping: # type: ignore

samples/client/3_0_3_unit_test/python/src/unit_test_api/schemas/format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ def parse_isodate_str(self, datestr: str) -> datetime.date:
8282
DEFAULT_ISOPARSER = CustomIsoparser()
8383

8484
@functools.lru_cache()
85-
def as_date_(arg: str) -> datetime.date:
85+
def as_date(arg: str) -> datetime.date:
8686
"""
8787
type = "string"
8888
format = "date"
8989
"""
9090
return DEFAULT_ISOPARSER.parse_isodate_str(arg)
9191

9292
@functools.lru_cache()
93-
def as_datetime_(arg: str) -> datetime.datetime:
93+
def as_datetime(arg: str) -> datetime.datetime:
9494
"""
9595
type = "string"
9696
format = "date-time"
9797
"""
9898
return DEFAULT_ISOPARSER.parse_isodatetime(arg)
9999

100100
@functools.lru_cache()
101-
def as_decimal_(arg: str) -> decimal.Decimal:
101+
def as_decimal(arg: str) -> decimal.Decimal:
102102
"""
103103
Applicable when storing decimals that are sent over the wire as strings
104104
type = "string"
@@ -107,7 +107,7 @@ def as_decimal_(arg: str) -> decimal.Decimal:
107107
return decimal.Decimal(arg)
108108

109109
@functools.lru_cache()
110-
def as_uuid_(arg: str) -> uuid.UUID:
110+
def as_uuid(arg: str) -> uuid.UUID:
111111
"""
112112
type = "string"
113113
format = "uuid"

samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
immutabledict
5353
)
5454
from .format import (
55-
as_date_,
56-
as_datetime_,
57-
as_decimal_,
58-
as_uuid_
55+
as_date,
56+
as_datetime,
57+
as_decimal,
58+
as_uuid
5959
)
6060

6161
def typed_dict_to_instance(t_dict: typing_extensions._TypedDictMeta) -> typing.Mapping: # type: ignore

samples/client/openapi_features/nonCompliantUseDiscriminatorIfCompositionFails/python/src/this_package/schemas/format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ def parse_isodate_str(self, datestr: str) -> datetime.date:
8282
DEFAULT_ISOPARSER = CustomIsoparser()
8383

8484
@functools.lru_cache()
85-
def as_date_(arg: str) -> datetime.date:
85+
def as_date(arg: str) -> datetime.date:
8686
"""
8787
type = "string"
8888
format = "date"
8989
"""
9090
return DEFAULT_ISOPARSER.parse_isodate_str(arg)
9191

9292
@functools.lru_cache()
93-
def as_datetime_(arg: str) -> datetime.datetime:
93+
def as_datetime(arg: str) -> datetime.datetime:
9494
"""
9595
type = "string"
9696
format = "date-time"
9797
"""
9898
return DEFAULT_ISOPARSER.parse_isodatetime(arg)
9999

100100
@functools.lru_cache()
101-
def as_decimal_(arg: str) -> decimal.Decimal:
101+
def as_decimal(arg: str) -> decimal.Decimal:
102102
"""
103103
Applicable when storing decimals that are sent over the wire as strings
104104
type = "string"
@@ -107,7 +107,7 @@ def as_decimal_(arg: str) -> decimal.Decimal:
107107
return decimal.Decimal(arg)
108108

109109
@functools.lru_cache()
110-
def as_uuid_(arg: str) -> uuid.UUID:
110+
def as_uuid(arg: str) -> uuid.UUID:
111111
"""
112112
type = "string"
113113
format = "uuid"

samples/client/openapi_features/security/python/src/this_package/schemas/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
immutabledict
5353
)
5454
from .format import (
55-
as_date_,
56-
as_datetime_,
57-
as_decimal_,
58-
as_uuid_
55+
as_date,
56+
as_datetime,
57+
as_decimal,
58+
as_uuid
5959
)
6060

6161
def typed_dict_to_instance(t_dict: typing_extensions._TypedDictMeta) -> typing.Mapping: # type: ignore

samples/client/openapi_features/security/python/src/this_package/schemas/format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ def parse_isodate_str(self, datestr: str) -> datetime.date:
8282
DEFAULT_ISOPARSER = CustomIsoparser()
8383

8484
@functools.lru_cache()
85-
def as_date_(arg: str) -> datetime.date:
85+
def as_date(arg: str) -> datetime.date:
8686
"""
8787
type = "string"
8888
format = "date"
8989
"""
9090
return DEFAULT_ISOPARSER.parse_isodate_str(arg)
9191

9292
@functools.lru_cache()
93-
def as_datetime_(arg: str) -> datetime.datetime:
93+
def as_datetime(arg: str) -> datetime.datetime:
9494
"""
9595
type = "string"
9696
format = "date-time"
9797
"""
9898
return DEFAULT_ISOPARSER.parse_isodatetime(arg)
9999

100100
@functools.lru_cache()
101-
def as_decimal_(arg: str) -> decimal.Decimal:
101+
def as_decimal(arg: str) -> decimal.Decimal:
102102
"""
103103
Applicable when storing decimals that are sent over the wire as strings
104104
type = "string"
@@ -107,7 +107,7 @@ def as_decimal_(arg: str) -> decimal.Decimal:
107107
return decimal.Decimal(arg)
108108

109109
@functools.lru_cache()
110-
def as_uuid_(arg: str) -> uuid.UUID:
110+
def as_uuid(arg: str) -> uuid.UUID:
111111
"""
112112
type = "string"
113113
format = "uuid"

samples/client/petstore/python/src/petstore_api/schemas/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
immutabledict
5353
)
5454
from .format import (
55-
as_date_,
56-
as_datetime_,
57-
as_decimal_,
58-
as_uuid_
55+
as_date,
56+
as_datetime,
57+
as_decimal,
58+
as_uuid
5959
)
6060

6161
def typed_dict_to_instance(t_dict: typing_extensions._TypedDictMeta) -> typing.Mapping: # type: ignore

samples/client/petstore/python/src/petstore_api/schemas/format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ def parse_isodate_str(self, datestr: str) -> datetime.date:
8282
DEFAULT_ISOPARSER = CustomIsoparser()
8383

8484
@functools.lru_cache()
85-
def as_date_(arg: str) -> datetime.date:
85+
def as_date(arg: str) -> datetime.date:
8686
"""
8787
type = "string"
8888
format = "date"
8989
"""
9090
return DEFAULT_ISOPARSER.parse_isodate_str(arg)
9191

9292
@functools.lru_cache()
93-
def as_datetime_(arg: str) -> datetime.datetime:
93+
def as_datetime(arg: str) -> datetime.datetime:
9494
"""
9595
type = "string"
9696
format = "date-time"
9797
"""
9898
return DEFAULT_ISOPARSER.parse_isodatetime(arg)
9999

100100
@functools.lru_cache()
101-
def as_decimal_(arg: str) -> decimal.Decimal:
101+
def as_decimal(arg: str) -> decimal.Decimal:
102102
"""
103103
Applicable when storing decimals that are sent over the wire as strings
104104
type = "string"
@@ -107,7 +107,7 @@ def as_decimal_(arg: str) -> decimal.Decimal:
107107
return decimal.Decimal(arg)
108108

109109
@functools.lru_cache()
110-
def as_uuid_(arg: str) -> uuid.UUID:
110+
def as_uuid(arg: str) -> uuid.UUID:
111111
"""
112112
type = "string"
113113
format = "uuid"

samples/client/petstore/python/tests_manual/test_any_type_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Model(AnyTypeSchema):
165165
m = Model.validate('12.34')
166166
assert m == '12.34'
167167
assert isinstance(m, str)
168-
assert schemas.as_decimal_(m) == Decimal('12.34')
168+
assert schemas.as_decimal(m) == Decimal('12.34')
169169

170170

171171
if __name__ == '__main__':

samples/client/petstore/python/tests_manual/test_composed_one_of_different_types.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,39 @@ def test_ComposedOneOfDifferentTypes(self):
5050
# date
5151
inst = composed_one_of_different_types.ComposedOneOfDifferentTypes.validate('2019-01-10')
5252
assert isinstance(inst, str)
53-
assert schemas.as_date_(inst).year == 2019
54-
assert schemas.as_date_(inst).month == 1
55-
assert schemas.as_date_(inst).day == 10
53+
assert schemas.as_date(inst).year == 2019
54+
assert schemas.as_date(inst).month == 1
55+
assert schemas.as_date(inst).day == 10
5656

5757
# date
5858
inst = composed_one_of_different_types.ComposedOneOfDifferentTypes.validate(date(2019, 1, 10))
5959
assert isinstance(inst, str)
60-
assert schemas.as_date_(inst).year == 2019
61-
assert schemas.as_date_(inst).month == 1
62-
assert schemas.as_date_(inst).day == 10
60+
assert schemas.as_date(inst).year == 2019
61+
assert schemas.as_date(inst).month == 1
62+
assert schemas.as_date(inst).day == 10
6363

6464
# date-time
6565
inst = composed_one_of_different_types.ComposedOneOfDifferentTypes.validate('2020-01-02T03:04:05Z')
6666
assert isinstance(inst, str)
67-
assert schemas.as_datetime_(inst).year == 2020
68-
assert schemas.as_datetime_(inst).month == 1
69-
assert schemas.as_datetime_(inst).day == 2
70-
assert schemas.as_datetime_(inst).hour == 3
71-
assert schemas.as_datetime_(inst).minute == 4
72-
assert schemas.as_datetime_(inst).second == 5
67+
assert schemas.as_datetime(inst).year == 2020
68+
assert schemas.as_datetime(inst).month == 1
69+
assert schemas.as_datetime(inst).day == 2
70+
assert schemas.as_datetime(inst).hour == 3
71+
assert schemas.as_datetime(inst).minute == 4
72+
assert schemas.as_datetime(inst).second == 5
7373
utc_tz = tzutc()
74-
assert schemas.as_datetime_(inst).tzinfo == utc_tz
74+
assert schemas.as_datetime(inst).tzinfo == utc_tz
7575

7676
# date-time
7777
inst = composed_one_of_different_types.ComposedOneOfDifferentTypes.validate(datetime(2020, 1, 2, 3, 4, 5, tzinfo=timezone.utc))
7878
assert isinstance(inst, str)
79-
assert schemas.as_datetime_(inst).year == 2020
80-
assert schemas.as_datetime_(inst).month == 1
81-
assert schemas.as_datetime_(inst).day == 2
82-
assert schemas.as_datetime_(inst).hour == 3
83-
assert schemas.as_datetime_(inst).minute == 4
84-
assert schemas.as_datetime_(inst).second == 5
85-
assert schemas.as_datetime_(inst).tzinfo == utc_tz
79+
assert schemas.as_datetime(inst).year == 2020
80+
assert schemas.as_datetime(inst).month == 1
81+
assert schemas.as_datetime(inst).day == 2
82+
assert schemas.as_datetime(inst).hour == 3
83+
assert schemas.as_datetime(inst).minute == 4
84+
assert schemas.as_datetime(inst).second == 5
85+
assert schemas.as_datetime(inst).tzinfo == utc_tz
8686

8787

8888
if __name__ == '__main__':

0 commit comments

Comments
 (0)