I'm implementing some REST API with flask. In one of the APIs, I need to submit a location defined by longitude and latitude. So naturally I'm doing this with httpie:
http POST :5000/api/v1.0/foo lng=12.34 lat=56.78
At the flask end, I'm using voluptuous to validate the JSON data. However, all the data that's received at the back end is of unicode
type. I have to do something like this:
try:
lng = atof(data['lng'])
schema(data)
except KeyError:
raise SomeError
except MultipleInvalid:
raise SomeError
This feels clunky and kind of beat the purpose of voluptuous. Am I doing in a wrong way or, is there a better way?