Skip to content

Commit

Permalink
Simplify ToJSON Responses
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Mar 8, 2016
1 parent 2064b96 commit 943ec04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Data/Swagger/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,7 @@ instance ToJSON ParamOtherSchema where
toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")

instance ToJSON Responses where
toJSON (Responses def rs) = omitEmpties $
toJSON (InsOrdHashMap.mapKeys show rs) <+> object [ "default" .= def ]
toJSON = omitEmpties . genericToJSONWithSub "responses" (jsonPrefix "responses")

instance ToJSON Response where
toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Swagger/Internal/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ genericParseJSONWithSub sub opts js@(Object o)
<|> genericParseJSON opts js' -- try with subjson
where
js' = Object (HashMap.insert sub (Object o) o)
genericParseJSONWithSub _ _ _ = error "genericParseJSONWithSub: given json is not an object"
genericParseJSONWithSub _ _ _ = fail "genericParseJSONWithSub: given json is not an object"

(<+>) :: Value -> Value -> Value
Object x <+> Object y = Object (x <> y)
Expand Down

0 comments on commit 943ec04

Please sign in to comment.