git.iko.soy/typeable/openapi3
on master help sign in
Validate non-required null fields
6f311cbNickolay Kudasov
src/Data/Swagger/Schema/Validation.hs+6−3
@@ -241,9 +241,12 @@ validateObject o = withSchema $ \schema ->
241
241
242 validateProps = withSchema $ \schema -> do
242 validateProps = withSchema $ \schema -> do
243 for_ (HashMap.toList o) $ \(k, v) ->
243 for_ (HashMap.toList o) $ \(k, v) ->
244+ case v of
245+ Null | not (k `elem` (schema ^. required)) -> valid -- null is fine for non-required property
246+ _ ->
244− case HashMap.lookup k (schema ^. properties) of
247+ case HashMap.lookup k (schema ^. properties) of
245− Nothing -> check additionalProperties $ \s -> sub s $ validateWithSchema v
248+ Nothing -> check additionalProperties $ \s -> sub s $ validateWithSchema v
246− Just s -> validateWithSchemaRef s v
249+ Just s -> validateWithSchemaRef s v
247
250
248validateEnum :: Value -> Validation (ParamSchema t) ()
251validateEnum :: Value -> Validation (ParamSchema t) ()
249validateEnum value = do
252validateEnum value = do