Commit 5fe15e23 authored by Jérome Perrin's avatar Jérome Perrin

fixup! open_api: more request body support

parent e9f0a931
......@@ -25,15 +25,11 @@
#
##############################################################################
import base64
import binascii
import json
import typing
from six.moves.urllib.parse import unquote
import six
if six.PY2:
from base64 import decodestring as base64_decodebytes
else:
from base64 import decodebytes as base64_decodebytes
if typing.TYPE_CHECKING:
from typing import Any, Callable, Optional
......@@ -313,7 +309,7 @@ class OpenAPIService(XMLObject):
if schema.get('type') == 'string':
if schema.get('format') == 'base64':
try:
return base64_decodebytes(parameter_value)
return base64.b64decode(parameter_value)
except binascii.Error as e:
raise ParameterValidationError(
'Error validating request body: {e}'.format(e=str(e)))
......
......@@ -26,10 +26,12 @@
##############################################################################
import six
# pylint:disable=no-name-in-module
if six.PY2:
from base64 import encodestring as base64_encodebytes
else:
from base64 import encodebytes as base64_encodebytes
# pylint:enable=no-name-in-module
import io
import json
import unittest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment