git.iko.soy/typeable/openapi3
on master help sign in
Simplify ToJSON Responses
b982c7dOleg Grenrus
src/Data/Swagger/Internal.hs+1−2
@@ -978,8 +978,7 @@ instance ToJSON ParamOtherSchema where
978 toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
978 toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "paramOtherSchema")
979
979
980instance ToJSON Responses where
980instance ToJSON Responses where
981− toJSON (Responses def rs) = omitEmpties $
981+ toJSON = omitEmpties . genericToJSONWithSub "responses" (jsonPrefix "responses")
982− toJSON (InsOrdHashMap.mapKeys show rs) <+> object [ "default" .= def ]
983
982
984instance ToJSON Response where
983instance ToJSON Response where
985 toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
984 toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
src/Data/Swagger/Internal/Utils.hs+1−1
@@ -111,7 +111,7 @@ genericParseJSONWithSub sub opts js@(Object o)
111 <|> genericParseJSON opts js' -- try with subjson
111 <|> genericParseJSON opts js' -- try with subjson
112 where
112 where
113 js' = Object (HashMap.insert sub (Object o) o)
113 js' = Object (HashMap.insert sub (Object o) o)
114−genericParseJSONWithSub _ _ _ = error "genericParseJSONWithSub: given json is not an object"
114+genericParseJSONWithSub _ _ _ = fail "genericParseJSONWithSub: given json is not an object"
115
115
116(<+>) :: Value -> Value -> Value
116(<+>) :: Value -> Value -> Value
117Object x <+> Object y = Object (x <> y)
117Object x <+> Object y = Object (x <> y)