@@ -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)
@@ -418,6 +420,7 @@ nullarySchema :: Schema
418nullarySchema = mempty
420nullarySchema = mempty
419 & schemaType .~ SwaggerArray
421 & schemaType .~ SwaggerArray
420 & schemaEnum ?~ [ toJSON () ]
422 & schemaEnum ?~ [ toJSON () ]
423+ & schemaItems ?~ SwaggerItemsArray []
422gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
425gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
423gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
426gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
@@ -425,9 +428,6 @@ gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
425gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
428gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
426gdeclareSchema opts proxy = snd <$> gdeclareNamedSchema opts proxy mempty
429gdeclareSchema 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
431instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
432 gdeclareNamedSchema opts _ schema = do
432 gdeclareNamedSchema opts _ schema = do
433 (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
433 (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
@@ -441,6 +441,9 @@ instance (Datatype d, GToSchema f) => GToSchema (D1 d f) where
441instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
441instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
442 gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
442 gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
444+instance {-# OVERLAPPING #-} Constructor c => GToSchema (C1 c U1) where
445+ gdeclareNamedSchema = gdeclareNamedSumSchema
444-- | Single field constructor.
447-- | Single field constructor.
445instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
448instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
446 gdeclareNamedSchema opts _ s
449 gdeclareNamedSchema opts _ s
@@ -511,16 +514,19 @@ instance {-# OVERLAPPABLE #-} ToSchema c => GToSchema (K1 i c) where
511 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
514 gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
513instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
516instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
514− gdeclareNamedSchema opts _ s
517+ gdeclareNamedSchema = gdeclareNamedSumSchema
519+gdeclareNamedSumSchema :: GSumToSchema f => SchemaOptions -> proxy f -> Schema -> Declare Definitions NamedSchema
520+gdeclareNamedSumSchema opts proxy s
515− | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
521+ | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
516− | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
522+ | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
518− declareSumSchema = gsumToSchema opts (Proxy :: Proxy (f :+: g)) s
524+ declareSumSchema = gsumToSchema opts proxy s
519− (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
525+ (sumSchema, All allNullary) = undeclare (runWriterT declareSumSchema)
521− toStringTag schema = mempty
527+ toStringTag schema = mempty
522− & schemaType .~ SwaggerString
528+ & schemaType .~ SwaggerString
523− & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
529+ & schemaEnum ?~ map toJSON (schema ^.. schemaProperties.ifolded.asIndex)
525type AllNullary = All
531type AllNullary = All