@@ -135,6 +135,7 @@ instance ToSchema a => ToSchema (Dual a) where toNamedSchema _ = unnamed $ to
135135data SchemaOptions = SchemaOptions
136136 { fieldLabelModifier :: String -> String
137137 , datatypeNameModifier :: String -> String
138+ , useReferences :: Bool
138139 , unwrapUnaryRecords :: Bool
139140 }
140141
@@ -142,6 +143,7 @@ defaultSchemaOptions :: SchemaOptions
142143defaultSchemaOptions = SchemaOptions
143144 { fieldLabelModifier = id
144145 , datatypeNameModifier = id
146+ , useReferences = True
145147 , unwrapUnaryRecords = False
146148 }
147149
@@ -196,7 +198,8 @@ instance (Datatype d, Selector s, GToSchema f) => GToSchema (D1 d (C1 c (S1 s f)
196198
197199gtoSchemaRef :: GToSchema f => SchemaOptions -> proxy f -> Referenced Schema
198200gtoSchemaRef opts proxy = case gtoNamedSchema opts proxy mempty of
199− (Just name, _) -> Ref (Reference ("#/definitions/" <> T.pack name))
201+ (Just name, _)
202+ | useReferences opts -> Ref (Reference ("#/definitions/" <> T.pack name))
200203 (_, schema) -> Inline schema
201204
202205appendItem :: Referenced Schema -> Maybe SchemaItems -> Maybe SchemaItems