Skip to content

Commit

Permalink
Update code after a rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
fizruk committed Dec 12, 2015
1 parent 3ea2118 commit 89078f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/Data/Swagger/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,9 @@ referencedToJSON :: ToJSON a => Text -> Referenced a -> Value
referencedToJSON prefix (Ref (Reference ref)) = object [ "$ref" .= (prefix <> ref) ]
referencedToJSON _ (Inline x) = toJSON x

instance ToJSON (Referenced Schema) where toJSON = referencedToJSON "#/definitions/"
instance ToJSON (Referenced Parameter) where toJSON = referencedToJSON "#/parameters/"
instance ToJSON (Referenced Response) where toJSON = referencedToJSON "#/responses/"
instance ToJSON (Referenced Schema) where toJSON = referencedToJSON "#/definitions/"
instance ToJSON (Referenced Param) where toJSON = referencedToJSON "#/parameters/"
instance ToJSON (Referenced Response) where toJSON = referencedToJSON "#/responses/"

instance ToJSON (SwaggerType t) where
toJSON SwaggerArray = "array"
Expand Down Expand Up @@ -976,9 +976,9 @@ referencedParseJSON prefix js@(Object o) = do
Nothing -> fail $ "expected $ref of the form \"" <> Text.unpack prefix <> "*\", but got " <> show s
Just suffix -> pure (Reference suffix)

instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
instance FromJSON (Referenced Parameter) where parseJSON = referencedParseJSON "#/parameters/"
instance FromJSON (Referenced Response) where parseJSON = referencedParseJSON "#/responses/"
instance FromJSON (Referenced Schema) where parseJSON = referencedParseJSON "#/definitions/"
instance FromJSON (Referenced Param) where parseJSON = referencedParseJSON "#/parameters/"
instance FromJSON (Referenced Response) where parseJSON = referencedParseJSON "#/responses/"

instance FromJSON Xml where
parseJSON = genericParseJSON (jsonPrefix "xml")
Expand Down
15 changes: 8 additions & 7 deletions src/Data/Swagger/Schema/Validation.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -87,13 +88,13 @@ validateWithSchema schema value

validateType =
case (schema ^. schemaType, value) of
(SchemaNull, Null) -> valid
(SchemaBoolean, Bool _) -> valid
(SchemaInteger, Number n) -> validateInteger n
(SchemaNumber, Number n) -> validateNumber n
(SchemaString, String s) -> validateString s
(SchemaArray, Array xs) -> validateArray xs
(SchemaObject, Object o) -> validateObject o
(SwaggerNull, Null) -> valid
(SwaggerBoolean, Bool _) -> valid
(SwaggerInteger, Number n) -> validateInteger n
(SwaggerNumber, Number n) -> validateNumber n
(SwaggerString, String s) -> validateString s
(SwaggerArray, Array xs) -> validateArray xs
(SwaggerObject, Object o) -> validateObject o
(t, _) -> invalid $ "expected JSON value of type " ++ show t ++ ": " ++ show (encode value)

validateInteger n
Expand Down

0 comments on commit 89078f4

Please sign in to comment.