1
+ {-# LANGUAGE UndecidableInstances #-}
1
2
{-# OPTIONS_GHC -fno-warn-orphans #-}
2
3
3
4
module Primer.OpenAPI (
4
5
-- * Orphan instances
5
6
-- $orphanInstances
6
7
) where
7
8
8
- import Data.OpenApi (ToSchema )
9
- import Data.Text (Text )
10
- import Data.Typeable (Typeable )
9
+ import Data.OpenApi (fromAesonOptions )
10
+ import Data.OpenApi.Internal.Schema
11
+ import Deriving.Aeson (AesonOptions (aesonOptions ))
12
+ import Foreword
11
13
import Primer.API (Def , Module , NodeBody , NodeFlavor , Prog , Tree )
12
14
import Primer.Core (GlobalName , ID (.. ), LVarName , ModuleName )
13
15
import Primer.Database (Session , SessionName )
16
+ import Primer.JSON (CustomJSON )
14
17
import Primer.Name (Name )
15
18
16
19
-- $orphanInstances
@@ -20,6 +23,13 @@ import Primer.Name (Name)
20
23
-- build primer with ghcjs, because openapi3 transitively depends on network,
21
24
-- which ghcjs currently cannot build.
22
25
26
+ -- Suitable for deriving via, when the ToJSON instance is via PrimerJSON
27
+ instance
28
+ (Typeable a , Generic a , GToSchema (Rep a ), Typeable os , Typeable ks , AesonOptions os ) =>
29
+ ToSchema (CustomJSON (os :: ks ) a )
30
+ where
31
+ declareNamedSchema _ = genericDeclareNamedSchema (fromAesonOptions (aesonOptions @ os )) (Proxy @ a )
32
+
23
33
instance ToSchema SessionName
24
34
instance ToSchema Session
25
35
0 commit comments