@@ -76,7 +76,7 @@ rename name (_, schema) = (name, schema)
76-- data Coord = Coord { x :: Double, y :: Double }
76-- data Coord = Coord { x :: Double, y :: Double }
78-- instance ToSchema Coord where
78-- instance ToSchema Coord where
79−-- toSchemaDefinitions = pure (Just "Coord", schema)
79+-- declareNamedSchema = pure (Just "Coord", schema)
81-- schema = mempty
81-- schema = mempty
82-- & schemaType .~ SwaggerObject
82-- & schemaType .~ SwaggerObject
@@ -88,11 +88,11 @@ rename name (_, schema) = (name, schema)
90-- Instead of manually writing your @'ToSchema'@ instance you can
90-- Instead of manually writing your @'ToSchema'@ instance you can
91−-- use a default generic implementation of @'toSchemaDefinitions'@.
91+-- use a default generic implementation of @'declareNamedSchema'@.
93-- To do that, simply add @deriving 'Generic'@ clause to your datatype
93-- To do that, simply add @deriving 'Generic'@ clause to your datatype
94-- and declare a @'ToSchema'@ instance for your datatype without
94-- and declare a @'ToSchema'@ instance for your datatype without
95−-- giving definition for @'toSchemaDefinitions'@.
95+-- giving definition for @'declareNamedSchema'@.
97-- For instance, the previous example can be simplified into this:
97-- For instance, the previous example can be simplified into this:
@@ -110,13 +110,13 @@ class ToSchema a where
110 -- together with all used definitions.
110 -- together with all used definitions.
111 -- Note that the schema itself is included in definitions
111 -- Note that the schema itself is included in definitions
112 -- only if it is recursive (and thus needs its definition in scope).
112 -- only if it is recursive (and thus needs its definition in scope).
113− toSchemaDefinitions :: proxy a -> Declare Definitions NamedSchema
113+ declareNamedSchema :: proxy a -> Declare Definitions NamedSchema
114− default toSchemaDefinitions :: (Generic a, GToSchema (Rep a)) => proxy a -> Declare Definitions NamedSchema
114+ default declareNamedSchema :: (Generic a, GToSchema (Rep a)) => proxy a -> Declare Definitions NamedSchema
115− toSchemaDefinitions = genericToSchemaDefinitions defaultSchemaOptions
115+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
117-- | Convert a type into an optionally named schema.
117-- | Convert a type into an optionally named schema.
118toNamedSchema :: ToSchema a => proxy a -> NamedSchema
118toNamedSchema :: ToSchema a => proxy a -> NamedSchema
119−toNamedSchema = undeclare . toSchemaDefinitions
119+toNamedSchema = undeclare . declareNamedSchema
121-- | Get type's schema name according to its @'ToSchema'@ instance.
121-- | Get type's schema name according to its @'ToSchema'@ instance.
122schemaName :: ToSchema a => proxy a -> Maybe String
122schemaName :: ToSchema a => proxy a -> Maybe String
@@ -127,7 +127,7 @@ toSchema :: ToSchema a => proxy a -> Schema
127toSchema = snd . toNamedSchema
127toSchema = snd . toNamedSchema
129declareSchema :: ToSchema a => proxy a -> Declare Definitions Schema
129declareSchema :: ToSchema a => proxy a -> Declare Definitions Schema
130−declareSchema = fmap snd . toSchemaDefinitions
130+declareSchema = fmap snd . declareNamedSchema
132-- | Convert a type into a referenced schema if possible.
132-- | Convert a type into a referenced schema if possible.
133-- Only named schemas can be references, nameless schemas are inlined.
133-- Only named schemas can be references, nameless schemas are inlined.
@@ -141,41 +141,41 @@ declareSchemaRef proxy = do
141 known <- looks (HashMap.member (T.pack name))
141 known <- looks (HashMap.member (T.pack name))
142 when (not known) $ do
142 when (not known) $ do
143 declare [(T.pack name, schema)]
143 declare [(T.pack name, schema)]
144− void $ toSchemaDefinitions proxy
144+ void $ declareNamedSchema proxy
145 return $ Ref (Reference ("#/definitions/" <> T.pack name))
145 return $ Ref (Reference ("#/definitions/" <> T.pack name))
146 _ -> Inline <$> declareSchema proxy
146 _ -> Inline <$> declareSchema proxy
148class GToSchema (f :: * -> *) where
148class GToSchema (f :: * -> *) where
149− gtoSchemaDefinitions :: SchemaOptions -> proxy f -> Schema -> Declare Definitions NamedSchema
149+ gdeclareNamedSchema :: SchemaOptions -> proxy f -> Schema -> Declare Definitions NamedSchema
151instance {-# OVERLAPPABLE #-} ToSchema a => ToSchema [a] where
151instance {-# OVERLAPPABLE #-} ToSchema a => ToSchema [a] where
152− toSchemaDefinitions _ = do
152+ declareNamedSchema _ = do
153 ref <- declareSchemaRef (Proxy :: Proxy a)
153 ref <- declareSchemaRef (Proxy :: Proxy a)
154 return $ unnamed $ mempty
154 return $ unnamed $ mempty
155 & schemaType .~ SwaggerArray
155 & schemaType .~ SwaggerArray
156 & schemaItems ?~ SchemaItemsObject ref
156 & schemaItems ?~ SchemaItemsObject ref
158−instance {-# OVERLAPPING #-} ToSchema String where toSchemaDefinitions = plain . paramSchemaToSchema
158+instance {-# OVERLAPPING #-} ToSchema String where declareNamedSchema = plain . paramSchemaToSchema
159−instance ToSchema Bool where toSchemaDefinitions = plain . paramSchemaToSchema
159+instance ToSchema Bool where declareNamedSchema = plain . paramSchemaToSchema
160−instance ToSchema Integer where toSchemaDefinitions = plain . paramSchemaToSchema
160+instance ToSchema Integer where declareNamedSchema = plain . paramSchemaToSchema
161−instance ToSchema Int where toSchemaDefinitions = plain . paramSchemaToSchema
161+instance ToSchema Int where declareNamedSchema = plain . paramSchemaToSchema
162−instance ToSchema Int8 where toSchemaDefinitions = plain . paramSchemaToSchema
162+instance ToSchema Int8 where declareNamedSchema = plain . paramSchemaToSchema
163−instance ToSchema Int16 where toSchemaDefinitions = plain . paramSchemaToSchema
163+instance ToSchema Int16 where declareNamedSchema = plain . paramSchemaToSchema
164−instance ToSchema Int32 where toSchemaDefinitions = plain . paramSchemaToSchema
164+instance ToSchema Int32 where declareNamedSchema = plain . paramSchemaToSchema
165−instance ToSchema Int64 where toSchemaDefinitions = plain . paramSchemaToSchema
165+instance ToSchema Int64 where declareNamedSchema = plain . paramSchemaToSchema
166−instance ToSchema Word where toSchemaDefinitions = plain . paramSchemaToSchema
166+instance ToSchema Word where declareNamedSchema = plain . paramSchemaToSchema
167−instance ToSchema Word8 where toSchemaDefinitions = plain . paramSchemaToSchema
167+instance ToSchema Word8 where declareNamedSchema = plain . paramSchemaToSchema
168−instance ToSchema Word16 where toSchemaDefinitions = plain . paramSchemaToSchema
168+instance ToSchema Word16 where declareNamedSchema = plain . paramSchemaToSchema
169−instance ToSchema Word32 where toSchemaDefinitions = plain . paramSchemaToSchema
169+instance ToSchema Word32 where declareNamedSchema = plain . paramSchemaToSchema
170−instance ToSchema Word64 where toSchemaDefinitions = plain . paramSchemaToSchema
170+instance ToSchema Word64 where declareNamedSchema = plain . paramSchemaToSchema
172−instance ToSchema Char where toSchemaDefinitions = plain . paramSchemaToSchema
172+instance ToSchema Char where declareNamedSchema = plain . paramSchemaToSchema
173−instance ToSchema Scientific where toSchemaDefinitions = plain . paramSchemaToSchema
173+instance ToSchema Scientific where declareNamedSchema = plain . paramSchemaToSchema
174−instance ToSchema Double where toSchemaDefinitions = plain . paramSchemaToSchema
174+instance ToSchema Double where declareNamedSchema = plain . paramSchemaToSchema
175−instance ToSchema Float where toSchemaDefinitions = plain . paramSchemaToSchema
175+instance ToSchema Float where declareNamedSchema = plain . paramSchemaToSchema
177instance ToSchema a => ToSchema (Maybe a) where
177instance ToSchema a => ToSchema (Maybe a) where
178− toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy a)
178+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy a)
180instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
180instance (ToSchema a, ToSchema b) => ToSchema (Either a b)
@@ -197,69 +197,69 @@ timeSchema format = mempty
197-- >>> toSchema (Proxy :: Proxy Day) ^. schemaFormat
197-- >>> toSchema (Proxy :: Proxy Day) ^. schemaFormat
198-- Just "yyyy-mm-dd"
198-- Just "yyyy-mm-dd"
199instance ToSchema Day where
199instance ToSchema Day where
200− toSchemaDefinitions _ = pure $ named "Day" (timeSchema "yyyy-mm-dd")
200+ declareNamedSchema _ = pure $ named "Day" (timeSchema "yyyy-mm-dd")
203-- >>> toSchema (Proxy :: Proxy LocalTime) ^. schemaFormat
203-- >>> toSchema (Proxy :: Proxy LocalTime) ^. schemaFormat
204-- Just "yyyy-mm-ddThh:MM:ss"
204-- Just "yyyy-mm-ddThh:MM:ss"
205instance ToSchema LocalTime where
205instance ToSchema LocalTime where
206− toSchemaDefinitions _ = pure $ named "LocalTime" (timeSchema "yyyy-mm-ddThh:MM:ss")
206+ declareNamedSchema _ = pure $ named "LocalTime" (timeSchema "yyyy-mm-ddThh:MM:ss")
209-- >>> toSchema (Proxy :: Proxy ZonedTime) ^. schemaFormat
209-- >>> toSchema (Proxy :: Proxy ZonedTime) ^. schemaFormat
210-- Just "yyyy-mm-ddThh:MM:ss(Z|+hh:MM)"
210-- Just "yyyy-mm-ddThh:MM:ss(Z|+hh:MM)"
211instance ToSchema ZonedTime where
211instance ToSchema ZonedTime where
212− toSchemaDefinitions _ = pure $ named "ZonedTime" $ timeSchema "yyyy-mm-ddThh:MM:ss(Z|+hh:MM)"
212+ declareNamedSchema _ = pure $ named "ZonedTime" $ timeSchema "yyyy-mm-ddThh:MM:ss(Z|+hh:MM)"
213 & schemaMinLength ?~ toInteger (length ("yyyy-mm-ddThh:MM:ssZ" :: String))
213 & schemaMinLength ?~ toInteger (length ("yyyy-mm-ddThh:MM:ssZ" :: String))
215instance ToSchema NominalDiffTime where
215instance ToSchema NominalDiffTime where
216− toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy Integer)
216+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy Integer)
219-- >>> toSchema (Proxy :: Proxy UTCTime) ^. schemaFormat
219-- >>> toSchema (Proxy :: Proxy UTCTime) ^. schemaFormat
220-- Just "yyyy-mm-ddThh:MM:ssZ"
220-- Just "yyyy-mm-ddThh:MM:ssZ"
221instance ToSchema UTCTime where
221instance ToSchema UTCTime where
222− toSchemaDefinitions _ = pure $ named "UTCTime" (timeSchema "yyyy-mm-ddThh:MM:ssZ")
222+ declareNamedSchema _ = pure $ named "UTCTime" (timeSchema "yyyy-mm-ddThh:MM:ssZ")
224−instance ToSchema T.Text where toSchemaDefinitions = plain . paramSchemaToSchema
224+instance ToSchema T.Text where declareNamedSchema = plain . paramSchemaToSchema
225−instance ToSchema TL.Text where toSchemaDefinitions = plain . paramSchemaToSchema
225+instance ToSchema TL.Text where declareNamedSchema = plain . paramSchemaToSchema
227−instance ToSchema IntSet where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Set Int))
227+instance ToSchema IntSet where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set Int))
229-- | NOTE: This schema does not account for the uniqueness of keys.
229-- | NOTE: This schema does not account for the uniqueness of keys.
230instance ToSchema a => ToSchema (IntMap a) where
230instance ToSchema a => ToSchema (IntMap a) where
231− toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy [(Int, a)])
231+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy [(Int, a)])
233instance ToSchema a => ToSchema (Map String a) where
233instance ToSchema a => ToSchema (Map String a) where
234− toSchemaDefinitions _ = do
234+ declareNamedSchema _ = do
235 schema <- declareSchema (Proxy :: Proxy a)
235 schema <- declareSchema (Proxy :: Proxy a)
236 return $ unnamed $ mempty
236 return $ unnamed $ mempty
237 & schemaType .~ SwaggerObject
237 & schemaType .~ SwaggerObject
238 & schemaAdditionalProperties ?~ schema
238 & schemaAdditionalProperties ?~ schema
240−instance ToSchema a => ToSchema (Map T.Text a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Map String a))
240+instance ToSchema a => ToSchema (Map T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
241−instance ToSchema a => ToSchema (Map TL.Text a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Map String a))
241+instance ToSchema a => ToSchema (Map TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
243−instance ToSchema a => ToSchema (HashMap String a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Map String a))
243+instance ToSchema a => ToSchema (HashMap String a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
244−instance ToSchema a => ToSchema (HashMap T.Text a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Map String a))
244+instance ToSchema a => ToSchema (HashMap T.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
245−instance ToSchema a => ToSchema (HashMap TL.Text a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Map String a))
245+instance ToSchema a => ToSchema (HashMap TL.Text a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Map String a))
247instance ToSchema a => ToSchema (Set a) where
247instance ToSchema a => ToSchema (Set a) where
248− toSchemaDefinitions _ = do
248+ declareNamedSchema _ = do
249 schema <- declareSchema (Proxy :: Proxy [a])
249 schema <- declareSchema (Proxy :: Proxy [a])
250 return $ unnamed $ schema
250 return $ unnamed $ schema
251 & schemaUniqueItems ?~ True
251 & schemaUniqueItems ?~ True
253−instance ToSchema a => ToSchema (HashSet a) where toSchemaDefinitions _ = toSchemaDefinitions (Proxy :: Proxy (Set a))
253+instance ToSchema a => ToSchema (HashSet a) where declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy (Set a))
255−instance ToSchema All where toSchemaDefinitions = plain . paramSchemaToSchema
255+instance ToSchema All where declareNamedSchema = plain . paramSchemaToSchema
256−instance ToSchema Any where toSchemaDefinitions = plain . paramSchemaToSchema
256+instance ToSchema Any where declareNamedSchema = plain . paramSchemaToSchema
258−instance ToSchema a => ToSchema (Sum a) where toSchemaDefinitions _ = unname <$> toSchemaDefinitions (Proxy :: Proxy a)
258+instance ToSchema a => ToSchema (Sum a) where declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
259−instance ToSchema a => ToSchema (Product a) where toSchemaDefinitions _ = unname <$> toSchemaDefinitions (Proxy :: Proxy a)
259+instance ToSchema a => ToSchema (Product a) where declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
260−instance ToSchema a => ToSchema (First a) where toSchemaDefinitions _ = unname <$> toSchemaDefinitions (Proxy :: Proxy a)
260+instance ToSchema a => ToSchema (First a) where declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
261−instance ToSchema a => ToSchema (Last a) where toSchemaDefinitions _ = unname <$> toSchemaDefinitions (Proxy :: Proxy a)
261+instance ToSchema a => ToSchema (Last a) where declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
262−instance ToSchema a => ToSchema (Dual a) where toSchemaDefinitions _ = unname <$> toSchemaDefinitions (Proxy :: Proxy a)
262+instance ToSchema a => ToSchema (Dual a) where declareNamedSchema _ = unname <$> declareNamedSchema (Proxy :: Proxy a)
264-- | Default schema for @'Bounded'@, @'Integral'@ types.
264-- | Default schema for @'Bounded'@, @'Integral'@ types.
265toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
265toSchemaBoundedIntegral :: forall a proxy. (Bounded a, Integral a) => proxy a -> Schema
@@ -282,14 +282,14 @@ genericToSchema opts = snd . genericToNamedSchema opts
283-- | A configurable generic @'NamedSchema'@ creator.
283-- | A configurable generic @'NamedSchema'@ creator.
284genericToNamedSchema :: (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> NamedSchema
284genericToNamedSchema :: (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> NamedSchema
285−genericToNamedSchema opts = undeclare . genericToSchemaDefinitions opts
285+genericToNamedSchema opts = undeclare . genericDeclareNamedSchema opts
287-- | A configurable generic @'NamedSchema'@ creator with declarations.
287-- | A configurable generic @'NamedSchema'@ creator with declarations.
288-- This function applied to @'defaultSchemaOptions'@
288-- This function applied to @'defaultSchemaOptions'@
289−-- is used as the default for @'toSchemaDefinitions'@
289+-- is used as the default for @'declareNamedSchema'@
290-- when the type is an instance of @'Generic'@.
290-- when the type is an instance of @'Generic'@.
291−genericToSchemaDefinitions :: forall a proxy. (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> Declare Definitions NamedSchema
291+genericDeclareNamedSchema :: forall a proxy. (Generic a, GToSchema (Rep a)) => SchemaOptions -> proxy a -> Declare Definitions NamedSchema
292−genericToSchemaDefinitions opts _ = gtoSchemaDefinitions opts (Proxy :: Proxy (Rep a)) mempty
292+genericDeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy (Rep a)) mempty
294gdatatypeSchemaName :: forall proxy d. Datatype d => SchemaOptions -> proxy d -> Maybe String
294gdatatypeSchemaName :: forall proxy d. Datatype d => SchemaOptions -> proxy d -> Maybe String
295gdatatypeSchemaName opts _ = case name of
295gdatatypeSchemaName opts _ = case name of
@@ -314,36 +314,36 @@ nullarySchema = mempty
314 & schemaEnum ?~ [ toJSON () ]
314 & schemaEnum ?~ [ toJSON () ]
316gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
316gtoNamedSchema :: GToSchema f => SchemaOptions -> proxy f -> NamedSchema
317−gtoNamedSchema opts proxy = undeclare $ gtoSchemaDefinitions opts proxy mempty
317+gtoNamedSchema opts proxy = undeclare $ gdeclareNamedSchema opts proxy mempty
319gtoSchema :: GToSchema f => SchemaOptions -> proxy f -> Schema
319gtoSchema :: GToSchema f => SchemaOptions -> proxy f -> Schema
320gtoSchema opts = snd . gtoNamedSchema opts
320gtoSchema opts = snd . gtoNamedSchema opts
322gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
322gdeclareSchema :: GToSchema f => SchemaOptions -> proxy f -> Declare Definitions Schema
323−gdeclareSchema opts proxy = snd <$> gtoSchemaDefinitions opts proxy mempty
323+gdeclareSchema opts proxy = snd <$> gdeclareNamedSchema opts proxy mempty
325gschemaName :: GToSchema f => SchemaOptions -> proxy f -> Maybe String
325gschemaName :: GToSchema f => SchemaOptions -> proxy f -> Maybe String
326gschemaName opts = fst . gtoNamedSchema opts
326gschemaName opts = fst . gtoNamedSchema opts
328instance GToSchema U1 where
328instance GToSchema U1 where
329− gtoSchemaDefinitions _ _ _ = plain nullarySchema
329+ gdeclareNamedSchema _ _ _ = plain nullarySchema
331instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
331instance (GToSchema f, GToSchema g) => GToSchema (f :*: g) where
332− gtoSchemaDefinitions opts _ schema = do
332+ gdeclareNamedSchema opts _ schema = do
333− (_, gschema) <- gtoSchemaDefinitions opts (Proxy :: Proxy g) schema
333+ (_, gschema) <- gdeclareNamedSchema opts (Proxy :: Proxy g) schema
334− gtoSchemaDefinitions opts (Proxy :: Proxy f) gschema
334+ gdeclareNamedSchema opts (Proxy :: Proxy f) gschema
336instance (Datatype d, GToSchema f) => GToSchema (D1 d f) where
336instance (Datatype d, GToSchema f) => GToSchema (D1 d f) where
337− gtoSchemaDefinitions opts _ s = rename name <$> gtoSchemaDefinitions opts (Proxy :: Proxy f) s
337+ gdeclareNamedSchema opts _ s = rename name <$> gdeclareNamedSchema opts (Proxy :: Proxy f) s
339 name = gdatatypeSchemaName opts (Proxy :: Proxy d)
339 name = gdatatypeSchemaName opts (Proxy :: Proxy d)
341instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
341instance {-# OVERLAPPABLE #-} GToSchema f => GToSchema (C1 c f) where
342− gtoSchemaDefinitions opts _ = gtoSchemaDefinitions opts (Proxy :: Proxy f)
342+ gdeclareNamedSchema opts _ = gdeclareNamedSchema opts (Proxy :: Proxy f)
344-- | Single field constructor.
344-- | Single field constructor.
345instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
345instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
346− gtoSchemaDefinitions opts _ s
346+ gdeclareNamedSchema opts _ s
347 | unwrapUnaryRecords opts = fieldSchema
347 | unwrapUnaryRecords opts = fieldSchema
348 | otherwise = do
348 | otherwise = do
349 (_, schema) <- recordSchema
349 (_, schema) <- recordSchema
@@ -351,8 +351,8 @@ instance (Selector s, GToSchema f) => GToSchema (C1 c (S1 s f)) where
351 Just (SchemaItemsArray [_]) -> fieldSchema
351 Just (SchemaItemsArray [_]) -> fieldSchema
352 _ -> pure (unnamed schema)
352 _ -> pure (unnamed schema)
354− recordSchema = gtoSchemaDefinitions opts (Proxy :: Proxy (S1 s f)) s
354+ recordSchema = gdeclareNamedSchema opts (Proxy :: Proxy (S1 s f)) s
355− fieldSchema = gtoSchemaDefinitions opts (Proxy :: Proxy f) s
355+ fieldSchema = gdeclareNamedSchema opts (Proxy :: Proxy f) s
357gdeclareSchemaRef :: GToSchema a => SchemaOptions -> proxy a -> Declare Definitions (Referenced Schema)
357gdeclareSchemaRef :: GToSchema a => SchemaOptions -> proxy a -> Declare Definitions (Referenced Schema)
358gdeclareSchemaRef opts proxy = do
358gdeclareSchemaRef opts proxy = do
@@ -361,7 +361,7 @@ gdeclareSchemaRef opts proxy = do
361 known <- looks (HashMap.member (T.pack name))
361 known <- looks (HashMap.member (T.pack name))
362 when (not known) $ do
362 when (not known) $ do
363 declare [(T.pack name, schema)]
363 declare [(T.pack name, schema)]
364− void $ gtoSchemaDefinitions opts proxy mempty
364+ void $ gdeclareNamedSchema opts proxy mempty
365 return $ Ref (Reference ("#/definitions/" <> T.pack name))
365 return $ Ref (Reference ("#/definitions/" <> T.pack name))
366 _ -> Inline <$> gdeclareSchema opts proxy
366 _ -> Inline <$> gdeclareSchema opts proxy
@@ -390,20 +390,20 @@ withFieldSchema opts _ isRequiredField schema = do
391-- | Optional record fields.
391-- | Optional record fields.
392instance {-# OVERLAPPING #-} (Selector s, ToSchema c) => GToSchema (S1 s (K1 i (Maybe c))) where
392instance {-# OVERLAPPING #-} (Selector s, ToSchema c) => GToSchema (S1 s (K1 i (Maybe c))) where
393− gtoSchemaDefinitions opts _ = fmap unnamed . withFieldSchema opts (Proxy2 :: Proxy2 s (K1 i (Maybe c))) False
393+ gdeclareNamedSchema opts _ = fmap unnamed . withFieldSchema opts (Proxy2 :: Proxy2 s (K1 i (Maybe c))) False
395-- | Record fields.
395-- | Record fields.
396instance {-# OVERLAPPABLE #-} (Selector s, GToSchema f) => GToSchema (S1 s f) where
396instance {-# OVERLAPPABLE #-} (Selector s, GToSchema f) => GToSchema (S1 s f) where
397− gtoSchemaDefinitions opts _ = fmap unnamed . withFieldSchema opts (Proxy2 :: Proxy2 s f) True
397+ gdeclareNamedSchema opts _ = fmap unnamed . withFieldSchema opts (Proxy2 :: Proxy2 s f) True
399instance {-# OVERLAPPING #-} ToSchema c => GToSchema (K1 i (Maybe c)) where
399instance {-# OVERLAPPING #-} ToSchema c => GToSchema (K1 i (Maybe c)) where
400− gtoSchemaDefinitions _ _ _ = toSchemaDefinitions (Proxy :: Proxy c)
400+ gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
402instance {-# OVERLAPPABLE #-} ToSchema c => GToSchema (K1 i c) where
402instance {-# OVERLAPPABLE #-} ToSchema c => GToSchema (K1 i c) where
403− gtoSchemaDefinitions _ _ _ = toSchemaDefinitions (Proxy :: Proxy c)
403+ gdeclareNamedSchema _ _ _ = declareNamedSchema (Proxy :: Proxy c)
405instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
405instance (GSumToSchema f, GSumToSchema g) => GToSchema (f :+: g) where
406− gtoSchemaDefinitions opts _ s
406+ gdeclareNamedSchema opts _ s
407 | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
407 | allNullaryToStringTag opts && allNullary = pure $ unnamed (toStringTag sumSchema)
408 | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema
408 | otherwise = (unnamed . fst) <$> runWriterT declareSumSchema