mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 11:09:53 +00:00
24 lines
502 B
Python
24 lines
502 B
Python
"""OpenAPI core schemas util module"""
|
|
import datetime
|
|
from distutils.util import strtobool
|
|
from json import dumps
|
|
from six import string_types
|
|
|
|
|
|
def forcebool(val):
|
|
if isinstance(val, string_types):
|
|
val = strtobool(val)
|
|
|
|
return bool(val)
|
|
|
|
|
|
def dicthash(d):
|
|
return hash(dumps(d, sort_keys=True))
|
|
|
|
|
|
def format_date(value):
|
|
return datetime.datetime.strptime(value, '%Y-%m-%d').date()
|
|
|
|
|
|
def format_datetime(value):
|
|
return datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
|