git.iko.soy/typeable/swagger2
on master help sign in
Stop producing unused definitions for generic schemas (#37)
37525ceNickolay Kudasov
src/Data/Swagger/Internal/Schema.hs+5−3
@@ -448,12 +448,14 @@ instance {-# OVERLAPPING #-} Constructor c => GToSchema (C1 c U1) where
448instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
448instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
449 gdeclareNamedSchema opts _ s
449 gdeclareNamedSchema opts _ s
450 | unwrapUnaryRecords opts = fieldSchema
450 | unwrapUnaryRecords opts = fieldSchema
451− | otherwise = do
451+ | otherwise =
452− (_, schema) <- recordSchema
453 case schema ^. schemaItems of
452 case schema ^. schemaItems of
454 Just (SwaggerItemsArray [_]) -> fieldSchema
453 Just (SwaggerItemsArray [_]) -> fieldSchema
454+ _ -> do
455+ declare defs
455− _ -> pure (unnamed schema)
456+ return (unnamed schema)
456 where
457 where
458+ (defs, (_, schema)) = runDeclare recordSchema mempty
457 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
459 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
458 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
460 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
459
461