mirror of
https://github.com/correl/openapi-core.git
synced 2025-04-13 01:01:11 -09:00
Merge pull request #99 from domenkozar/date-time-rfc3339
openapi 3.0 defines date-time format to be rfc3339
This commit is contained in:
commit
78cf590ec8
4 changed files with 7 additions and 3 deletions
|
@ -3,6 +3,7 @@ import datetime
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
import strict_rfc3339
|
||||||
|
|
||||||
|
|
||||||
def forcebool(val):
|
def forcebool(val):
|
||||||
|
@ -21,4 +22,5 @@ def format_date(value):
|
||||||
|
|
||||||
|
|
||||||
def format_datetime(value):
|
def format_datetime(value):
|
||||||
return datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
|
timestamp = strict_rfc3339.rfc3339_to_timestamp(value)
|
||||||
|
return datetime.datetime.fromtimestamp(timestamp)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
openapi-spec-validator
|
openapi-spec-validator
|
||||||
six
|
six
|
||||||
lazy-object-proxy
|
lazy-object-proxy
|
||||||
|
strict_rfc3339
|
||||||
attrs
|
attrs
|
||||||
|
|
|
@ -4,4 +4,5 @@ lazy-object-proxy
|
||||||
backports.functools-lru-cache
|
backports.functools-lru-cache
|
||||||
backports.functools-partialmethod
|
backports.functools-partialmethod
|
||||||
enum34
|
enum34
|
||||||
|
strict_rfc3339
|
||||||
attrs
|
attrs
|
||||||
|
|
|
@ -81,11 +81,11 @@ class TestSchemaUnmarshal(object):
|
||||||
|
|
||||||
def test_string_format_datetime(self):
|
def test_string_format_datetime(self):
|
||||||
schema = Schema('string', schema_format='date-time')
|
schema = Schema('string', schema_format='date-time')
|
||||||
value = '2018-01-02T00:00:00'
|
value = '2018-01-02T00:00:00Z'
|
||||||
|
|
||||||
result = schema.unmarshal(value)
|
result = schema.unmarshal(value)
|
||||||
|
|
||||||
assert result == datetime.datetime(2018, 1, 2, 0, 0, 0)
|
assert result == datetime.datetime(2018, 1, 2, 0, 0)
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="No custom formats support atm")
|
@pytest.mark.xfail(reason="No custom formats support atm")
|
||||||
def test_string_format_custom(self):
|
def test_string_format_custom(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue