git.iko.soy/typeable/openapi3
on master help sign in
Add comment for GToSchema fix
be57718Maxim Koltsov
src/Data/OpenApi/Internal/Schema.hs+6−3
@@ -945,10 +945,13 @@ instance (Selector s, GToSchema f, GToSchema (S1 s f)) => GToSchema (C1 c (S1 s
945 case schema ^. items of
945 case schema ^. items of
946 Just (OpenApiItemsArray [_]) -> fieldSchema
946 Just (OpenApiItemsArray [_]) -> fieldSchema
947 _ -> do
947 _ -> do
948+ -- We have to run recordSchema instead of just using its defs,
949+ -- since those can be recursive and will lead to infinite loop,
950+ -- see https://github.com/biocad/openapi3/pull/37
948− NamedSchema _ schema <- recordSchema
951+ NamedSchema _ schema' <- recordSchema
949− return (unnamed schema)
952+ return (unnamed schema')
950 where
953 where
951− (defs, NamedSchema _ schema) = runDeclare recordSchema mempty
954+ (_, NamedSchema _ schema) = runDeclare recordSchema mempty
952 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
955 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
953 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
956 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
954
957