@@ -64,6 +64,7 @@ import Data.Swagger.Internal.ParamSchema (ToParamSchema(..))
6464import Data.Swagger.Lens hiding (name, schema)
6565import qualified Data.Swagger.Lens as Swagger
6666import Data.Swagger.SchemaOptions
67+import Data.Swagger.Internal.TypeShape
6768
6869#if __GLASGOW_HASKELL__ < 800
6970#else
@@ -708,7 +709,12 @@ instance OVERLAPPING_ ToSchema c => GToSchema (K1 i (Maybe c)) where
708709instance OVERLAPPABLE_ ToSchema c => GToSchema (K1 i c) where
709710 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
710711
711−instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
712+instance ( GSumToSchema f
713+ , GSumToSchema g
714+ , LegalShape (GenericShape (f :+: g))
715+
716+ ) => GToSchema (f :+: g)
717+ where
712718 gdeclareNamedSchema = gdeclareNamedSumSchema
713719
714720gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> proxy f -> Schema -> Declare (Definitions Schema) NamedSchema