@@ -945,10 +945,13 @@ instance (Selector s, GToSchema f, GToSchema (S1 s f)) => GToSchema (C1 c (S1 s
945945 case schema ^. items of
946946 Just (OpenApiItemsArray [_]) -> fieldSchema
947947 _ -> do
948− NamedSchema _ schema <- recordSchema
949− return (unnamed schema)
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
951+ NamedSchema _ schema' <- recordSchema
952+ return (unnamed schema')
950953 where
951− (defs, NamedSchema _ schema) = runDeclare recordSchema mempty
954+ (_, NamedSchema _ schema) = runDeclare recordSchema mempty
952955 recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
953956 fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
954957