Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
198
Issues
198
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
c45199f7
Commit
c45199f7
authored
Sep 10, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] some fixes to sum types JSON serialization
parent
9bd89984
Pipeline
#1799
passed with stage
in 33 minutes and 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
28 deletions
+22
-28
Contact.hs
src/Gargantext/API/Node/Contact.hs
+3
-2
Public.hs
src/Gargantext/API/Public.hs
+3
-2
Search.hs
src/Gargantext/API/Search.hs
+16
-24
No files found.
src/Gargantext/API/Node/Contact.hs
View file @
c45199f7
...
@@ -46,6 +46,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataAnnuaire(..), Hyperda
...
@@ -46,6 +46,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataAnnuaire(..), Hyperda
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
hyperdataContact
)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
hyperdataContact
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Prelude
((
$
),
liftBase
,
(
.
),
printDebug
,
pure
)
import
Gargantext.Prelude
((
$
),
liftBase
,
(
.
),
printDebug
,
pure
)
import
qualified
Gargantext.Utils.Aeson
as
GUA
------------------------------------------------------------------------
------------------------------------------------------------------------
type
API
=
"contact"
:>
Summary
"Contact endpoint"
type
API
=
"contact"
:>
Summary
"Contact endpoint"
...
@@ -105,10 +106,10 @@ addContact _uId _nId _p logStatus = do
...
@@ -105,10 +106,10 @@ addContact _uId _nId _p logStatus = do
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
AddContactParams
where
instance
FromJSON
AddContactParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
AddContactParams
where
instance
ToJSON
AddContactParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
AddContactParams
instance
ToSchema
AddContactParams
instance
Arbitrary
AddContactParams
where
instance
Arbitrary
AddContactParams
where
...
...
src/Gargantext/API/Public.hs
View file @
c45199f7
...
@@ -42,6 +42,7 @@ import Gargantext.Database.Query.Table.NodeNode (selectPublicNodes)
...
@@ -42,6 +42,7 @@ import Gargantext.Database.Query.Table.NodeNode (selectPublicNodes)
import
Gargantext.Core.Utils.DateUtils
(
utc2year
)
import
Gargantext.Core.Utils.DateUtils
(
utc2year
)
import
Gargantext.Database.Schema.Node
-- (NodePoly(..))
import
Gargantext.Database.Schema.Node
-- (NodePoly(..))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Gargantext.Utils.Aeson
as
GUA
------------------------------------------------------------------------
------------------------------------------------------------------------
type
API
=
API_Home
type
API
=
API_Home
...
@@ -138,10 +139,10 @@ data PublicData = PublicData
...
@@ -138,10 +139,10 @@ data PublicData = PublicData
instance
FromJSON
PublicData
where
instance
FromJSON
PublicData
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToJSON
PublicData
where
instance
ToJSON
PublicData
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
GUA
.
defaultTaggedObject
})
instance
ToSchema
PublicData
instance
ToSchema
PublicData
instance
Arbitrary
PublicData
where
instance
Arbitrary
PublicData
where
...
...
src/Gargantext/API/Search.hs
View file @
c45199f7
...
@@ -75,12 +75,10 @@ api nId (SearchQuery q SearchContact) o l order = do
...
@@ -75,12 +75,10 @@ api nId (SearchQuery q SearchContact) o l order = do
-----------------------------------------------------------------------
-----------------------------------------------------------------------
data
SearchType
=
SearchDoc
|
SearchContact
data
SearchType
=
SearchDoc
|
SearchContact
deriving
(
Generic
)
deriving
(
Generic
)
instance
FromJSON
SearchType
instance
FromJSON
SearchType
where
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToJSON
SearchType
where
instance
ToJSON
SearchType
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToSchema
SearchType
instance
ToSchema
SearchType
instance
Arbitrary
SearchType
where
instance
Arbitrary
SearchType
where
arbitrary
=
elements
[
SearchDoc
,
SearchContact
]
arbitrary
=
elements
[
SearchDoc
,
SearchContact
]
...
@@ -91,12 +89,10 @@ data SearchQuery =
...
@@ -91,12 +89,10 @@ data SearchQuery =
,
expected
::
!
SearchType
,
expected
::
!
SearchType
}
}
deriving
(
Generic
)
deriving
(
Generic
)
instance
FromJSON
SearchQuery
instance
FromJSON
SearchQuery
where
where
parseJSON
=
genericParseJSON
defaultOptions
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToJSON
SearchQuery
where
instance
ToJSON
SearchQuery
toJSON
=
genericToJSON
defaultOptions
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToSchema
SearchQuery
instance
ToSchema
SearchQuery
{-
{-
where
where
...
@@ -111,13 +107,11 @@ data SearchResult =
...
@@ -111,13 +107,11 @@ data SearchResult =
SearchResult
{
result
::
!
SearchResultTypes
}
SearchResult
{
result
::
!
SearchResultTypes
}
deriving
(
Generic
)
deriving
(
Generic
)
instance
FromJSON
SearchResult
instance
FromJSON
SearchResult
where
where
parseJSON
=
genericParseJSON
defaultOptions
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToJSON
SearchResult
instance
ToJSON
SearchResult
where
where
toJSON
=
genericToJSON
defaultOptions
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToSchema
SearchResult
instance
ToSchema
SearchResult
{-
{-
...
@@ -134,12 +128,10 @@ data SearchResultTypes =
...
@@ -134,12 +128,10 @@ data SearchResultTypes =
|
SearchResultContact
{
contacts
::
!
[
Row
]
}
|
SearchResultContact
{
contacts
::
!
[
Row
]
}
|
SearchNoResult
{
message
::
!
Text
}
|
SearchNoResult
{
message
::
!
Text
}
deriving
(
Generic
)
deriving
(
Generic
)
instance
FromJSON
SearchResultTypes
instance
FromJSON
SearchResultTypes
where
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
defaultTaggedObject
})
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
defaultTaggedObject
})
instance
ToJSON
SearchResultTypes
where
instance
ToJSON
SearchResultTypes
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
defaultTaggedObject
})
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
defaultTaggedObject
})
instance
Arbitrary
SearchResultTypes
where
instance
Arbitrary
SearchResultTypes
where
arbitrary
=
do
arbitrary
=
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment