-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Description
Using LTS 9.9 with swagger2-2.1.6 or, alternatively, the current main branch of the repository:
When using the option genericDeclareNamedSchema in combination with recursive data types, the produced schema grows unbounded. Here is a standalone example:
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Data.Proxy
import Data.Swagger
import Data.Swagger.Declare
import GHC.Generics
data SomeTy =
SomeCon { keyA :: Int, keyB :: Maybe SomeTy }
deriving (Eq, Show, Generic)
instance ToSchema SomeTy where
declareNamedSchema = genericDeclareNamedSchema schemaOpts
schemaOpts = defaultSchemaOptions
{ Data.Swagger.datatypeNameModifier = drop 1 }
proxySomeTy :: Proxy SomeTy
proxySomeTy = Proxy
testSomeTy :: NamedSchema
testSomeTy = undeclare $ declareNamedSchema proxySomeTy
main :: IO ()
main = putStrLn (show testSomeTy)
My best guess would be that the transformed name is not taken properly in account when checking for recursion.
Metadata
Metadata
Assignees
Labels
No labels