@@ -292,7 +292,9 @@ instance ToSchema a => ToSchema (Maybe a) where
293instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
293instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
295−instance ToSchema ()
295+instance ToSchema () where
296+ declareNamedSchema _ = pure (Nothing, nullarySchema)
296instance (ToSchema a, ToSchema b) => ToSchema (a, b)
298instance (ToSchema a, ToSchema b) => ToSchema (a, b)
297instance (ToSchema a, ToSchema b, ToSchema c) => ToSchema (a, b, c)
299instance (ToSchema a, ToSchema b, ToSchema c) => ToSchema (a, b, c)
298instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d) => ToSchema (a, b, c, d)
300instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d) => ToSchema (a, b, c, d)
@@ -425,9 +427,6 @@ gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
425gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
427gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
426gdeclareSchema opts proxy = snd <$> gdeclareNamedSchema opts proxy mempty
428gdeclareSchema opts proxy = snd <$> gdeclareNamedSchema opts proxy mempty
428−instance GToSchema U1 where
429− gdeclareNamedSchema _ _ _ = plain nullarySchema
431instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
430instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
432 gdeclareNamedSchema opts _ schema = do
431 gdeclareNamedSchema opts _ schema = do
433 (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
432 (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
@@ -441,6 +440,9 @@ instance (Datatype d, GToSchema f) => GToSchema (D1 d f) where
441instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
440instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
442 gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
441 gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
443+instance {-# OVERLAPPING #-} Constructor c => GToSchema (C1 c U1) where
444+ gdeclareNamedSchema = gdeclareNamedSumSchema
444-- | Single field constructor.
446-- | Single field constructor.
445instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
447instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
446 gdeclareNamedSchema opts _ s
448 gdeclareNamedSchema opts _ s
@@ -511,16 +513,19 @@ instance {-# OVERLAPPABLE #-} ToSchema c => GToSchema (K1 i c) where
511 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
513 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
513instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
515instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
514− gdeclareNamedSchema opts _ s
516+ gdeclareNamedSchema = gdeclareNamedSumSchema
518+gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> proxy f -> Schema -> Declare Definitions NamedSchema
519+gdeclareNamedSumSchema opts proxy s
515− | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
520+ | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
516− | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
521+ | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
518− declareSumSchema = gsumToSchema opts (Proxy :: Proxy (f :+: g)) s
523+ declareSumSchema = gsumToSchema opts proxy s
519− (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
524+ (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
521− toStringTag schema = mempty
526+ toStringTag schema = mempty
522− & schemaType .~ SwaggerString
527+ & schemaType .~ SwaggerString
523− & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
528+ & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
525type AllNullary = All
530type AllNullary = All