@@ -22,6 +22,9 @@
22-- Validate JSON values with Swagger Schema.
22-- Validate JSON values with Swagger Schema.
23module Data.Swagger.Internal.Schema.Validation where
23module Data.Swagger.Internal.Schema.Validation where
25import Control.Applicative
28import Control.Applicative
26import Control.Lens
29import Control.Lens
27import Control.Monad (when)
30import Control.Monad (when)
@@ -34,8 +37,6 @@ import Data.HashMap.Strict (HashMap)
34import qualified Data.HashMap.Strict as HashMap
37import qualified Data.HashMap.Strict as HashMap
35import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
38import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
36import qualified "unordered-containers" Data.HashSet as HashSet
39import qualified "unordered-containers" Data.HashSet as HashSet
37−import Data.List (intercalate)
39import Data.Proxy
40import Data.Proxy
40import Data.Scientific (Scientific, isInteger)
41import Data.Scientific (Scientific, isInteger)
41import Data.Text (Text)
42import Data.Text (Text)
@@ -483,7 +484,7 @@ validateSchemaType value = withSchema $ \sch ->
483 (Nothing, String s) -> sub_ paramSchema (validateString s)
484 (Nothing, String s) -> sub_ paramSchema (validateString s)
484 (Nothing, Array xs) -> sub_ paramSchema (validateArray xs)
485 (Nothing, Array xs) -> sub_ paramSchema (validateArray xs)
485 (Nothing, Object o) -> validateObject o
486 (Nothing, Object o) -> validateObject o
486− param@(t, _) -> invalid $ "expected JSON value of type " ++ showType param
487+ bad -> invalid $ "expected JSON value of type " ++ showType bad
488validateParamSchemaType :: Value -> Validation (ParamSchema t) ()
489validateParamSchemaType :: Value -> Validation (ParamSchema t) ()
489validateParamSchemaType value = withSchema $ \sch ->
490validateParamSchemaType value = withSchema $ \sch ->
@@ -498,8 +499,7 @@ validateParamSchemaType value = withSchema $ \sch ->
498 (Nothing, Number n) -> validateNumber n
499 (Nothing, Number n) -> validateNumber n
499 (Nothing, String s) -> validateString s
500 (Nothing, String s) -> validateString s
500 (Nothing, Array xs) -> validateArray xs
501 (Nothing, Array xs) -> validateArray xs
501− (t, _) -> invalid $ "expected JSON value of type " ++ show t
502− param@(t, _) -> invalid $ "expected JSON value of type " ++ showType param
502+ bad -> invalid $ "expected JSON value of type " ++ showType bad
504showType :: (Maybe (SwaggerType t), Value) -> String
504showType :: (Maybe (SwaggerType t), Value) -> String
505showType (Just type_, _) = show type_
505showType (Just type_, _) = show type_