@@ -292,7 +292,9 @@ instance ToSchema a => ToSchema (Maybe a) where
292292
293293instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
294294
295−instance ToSchema ()
295+instance ToSchema () where
296+ declareNamedSchema _ = pure (Nothing, nullarySchema)
297+
296298instance (ToSchema a, ToSchema b) => ToSchema (a, b)
297299instance (ToSchema a, ToSchema b, ToSchema c) => ToSchema (a, b, c)
298300instance (ToSchema a, ToSchema b, ToSchema c, ToSchema d) => ToSchema (a, b, c, d)
@@ -418,6 +420,7 @@ nullarySchema :: Schema
418420nullarySchema = mempty
419421 & schemaType .~ SwaggerArray
420422 & schemaEnum ?~ [ toJSON () ]
423+ & schemaItems ?~ SwaggerItemsArray []
421424
422425gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
423426gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
@@ -425,9 +428,6 @@ gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
425428gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
426429gdeclareSchema opts proxy = snd <$> gdeclareNamedSchema opts proxy mempty
427430
428−instance GToSchema U1 where
429− gdeclareNamedSchema _ _ _ = plain nullarySchema
430−
431431instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
432432 gdeclareNamedSchema opts _ schema = do
433433 (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
@@ -441,6 +441,9 @@ instance (Datatype d, GToSchema f) => GToSchema (D1 d f) where
441441instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
442442 gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
443443
444+instance {-# OVERLAPPING #-} Constructor c => GToSchema (C1 c U1) where
445+ gdeclareNamedSchema = gdeclareNamedSumSchema
446+
444447-- | Single field constructor.
445448instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
446449 gdeclareNamedSchema opts _ s
@@ -511,16 +514,19 @@ instance {-# OVERLAPPABLE #-} ToSchema c => GToSchema (K1 i c) where
511514 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
512515
513516instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
514− gdeclareNamedSchema opts _ s
515− | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
516− | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
517− where
518− declareSumSchema = gsumToSchema opts (Proxy :: Proxy (f :+: g)) s
519− (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
517+ gdeclareNamedSchema = gdeclareNamedSumSchema
518+
519+gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> proxy f -> Schema -> Declare Definitions NamedSchema
520+gdeclareNamedSumSchema opts proxy s
521+ | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
522+ | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
523+ where
524+ declareSumSchema = gsumToSchema opts proxy s
525+ (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
520526
521− toStringTag schema = mempty
522− & schemaType .~ SwaggerString
523− & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
527+ toStringTag schema = mempty
528+ & schemaType .~ SwaggerString
529+ & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
524530
525531type AllNullary = All
526532