@@ -722,9 +722,6 @@ deriveJSONDefault ''Scheme
722deriveJSON' ''Tag
722deriveJSON' ''Tag
723deriveJSON' ''ExternalDocs
723deriveJSON' ''ExternalDocs
725−deriveToJSON' ''Operation
726−deriveToJSON' ''Response
727−deriveToJSON' ''PathItem
728deriveToJSON' ''Xml
725deriveToJSON' ''Xml
730-- =======================================================================
727-- =======================================================================
@@ -747,7 +744,7 @@ instance ToJSON OAuth2Flow where
747 , "tokenUrl" .= tokenUrl ]
744 , "tokenUrl" .= tokenUrl ]
749instance ToJSON OAuth2Params where
746instance ToJSON OAuth2Params where
750− toJSON = genericToJSONWithSub "flow" (jsonPrefix "oauth2")
747+ toJSON = omitEmpties . genericToJSONWithSub "flow" (jsonPrefix "oauth2")
752instance ToJSON SecuritySchemeType where
749instance ToJSON SecuritySchemeType where
753 toJSON SecuritySchemeBasic
750 toJSON SecuritySchemeBasic
@@ -760,7 +757,7 @@ instance ToJSON SecuritySchemeType where
760 <+> object [ "type" .= ("oauth2" :: Text) ]
757 <+> object [ "type" .= ("oauth2" :: Text) ]
762instance ToJSON Swagger where
759instance ToJSON Swagger where
763− toJSON = addVersion . genericToJSON (jsonPrefix "")
760+ toJSON = omitEmpties . addVersion . genericToJSON (jsonPrefix "")
765 addVersion (Object o) = Object (HashMap.insert "swagger" "2.0" o)
762 addVersion (Object o) = Object (HashMap.insert "swagger" "2.0" o)
766 addVersion _ = error "impossible"
763 addVersion _ = error "impossible"
@@ -769,7 +766,7 @@ instance ToJSON SecurityScheme where
769 toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
766 toJSON = genericToJSONWithSub "type" (jsonPrefix "securityScheme")
771instance ToJSON Schema where
768instance ToJSON Schema where
772− toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "schema")
769+ toJSON = omitEmpties . genericToJSONWithSub "paramSchema" (jsonPrefix "schema")
774instance ToJSON Header where
771instance ToJSON Header where
775 toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "header")
772 toJSON = genericToJSONWithSub "paramSchema" (jsonPrefix "header")
@@ -804,7 +801,17 @@ instance ToJSON SchemaItems where
804 toJSON (SchemaItemsArray xs) = toJSON xs
801 toJSON (SchemaItemsArray xs) = toJSON xs
806instance ToJSON Responses where
803instance ToJSON Responses where
804+ toJSON (Responses def rs) = omitEmpties $
807− toJSON (Responses def rs) = toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
805+ toJSON (hashMapMapKeys show rs) <+> object [ "default" .= def ]
807+instance ToJSON Response where
808+ toJSON = omitEmpties . genericToJSON (jsonPrefix "response")
810+instance ToJSON Operation where
811+ toJSON = omitEmpties . genericToJSON (jsonPrefix "operation")
813+instance ToJSON PathItem where
814+ toJSON = omitEmpties . genericToJSON (jsonPrefix "pathItem")
809instance ToJSON Example where
816instance ToJSON Example where
810 toJSON = toJSON . Map.mapKeys show . getExample
817 toJSON = toJSON . Map.mapKeys show . getExample