# Path: falconswagger/exceptions.py
# class ModelBaseError(FalconSwaggerError):
#     def __init__(self, message, input_=None):
#         FalconSwaggerError.__init__(self, message, HTTP_BAD_REQUEST)
#         self.input_ = input_


from falconswagger.exceptions import ModelBaseError
from jsonschema import ValidationError
from copy import deepcopy
import json
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.




class JsonBuilderMeta(type):

    def _type_builder(cls, type_):
        return getattr(cls, '_build_' + type_)

    def _build_string(cls, value):
        return str(value)

    def _build_number(cls, value):
        return float(value)

    def _build_boolean(cls, value):
        value = json.loads(value)
        if not isinstance(value, bool):
            raise ValueError(value)
        return value

    def _build_integer(cls, value):
        return int(value)

    def _build_array(cls, values, schema, nested_types, input_):
        if 'array' in nested_types:

# Path: falconswagger/exceptions.py
# class ModelBaseError(FalconSwaggerError):
#     def __init__(self, message, input_=None):
#         FalconSwaggerError.__init__(self, message, HTTP_BAD_REQUEST)
#         self.input_ = input_


# Path: falconswagger/json_builder.py
from falconswagger.exceptions import ModelBaseError
from jsonschema import ValidationError
from copy import deepcopy
import json

# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.




class JsonBuilderMeta(type):

    def _type_builder(cls, type_):
        return getattr(cls, '_build_' + type_)

    def _build_string(cls, value):
        return str(value)

    def _build_number(cls, value):
        return float(value)

    def _build_boolean(cls, value):
        value = json.loads(value)
        if not isinstance(value, bool):
            raise ValueError(value)
        return value

    def _build_integer(cls, value):
        return int(value)

    def _build_array(cls, values, schema, nested_types, input_):
        if 'array' in nested_types:

            raise ModelBaseError('nested array was not allowed', input_=input_)