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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
8d65a86c
Commit
8d65a86c
authored
Oct 08, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: move the swaggerDoc to its own module
parent
6359811d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
27 deletions
+40
-27
API.hs
src/Gargantext/API.hs
+3
-27
Swagger.hs
src/Gargantext/API/Swagger.hs
+37
-0
No files found.
src/Gargantext/API.hs
View file @
8d65a86c
...
...
@@ -44,9 +44,7 @@ import Control.Exception (finally)
import
Control.Lens
import
Control.Monad.Except
(
withExceptT
)
import
Control.Monad.Reader
(
runReaderT
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
Data.List
(
lookup
)
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text.Encoding
(
encodeUtf8
)
import
Data.Validity
...
...
@@ -61,9 +59,7 @@ import Network.Wai.Middleware.Cors
import
Network.Wai.Middleware.RequestLogger
import
Servant
import
Servant.Auth.Server
(
AuthResult
(
..
))
import
Servant.Auth.Swagger
()
import
Servant.Swagger
import
Servant.Swagger.UI
import
Servant.Swagger.UI
(
swaggerSchemaUIServer
)
import
System.IO
(
FilePath
)
import
qualified
Data.ByteString.Lazy.Char8
as
BL8
import
qualified
Data.Text.IO
as
T
...
...
@@ -80,6 +76,7 @@ import Gargantext.API.Ngrams (saveRepo)
import
Gargantext.API.Ngrams.Types
(
HasRepoSaver
(
..
))
import
Gargantext.API.Prelude
import
Gargantext.API.Routes
import
Gargantext.API.Swagger
(
swaggerDoc
)
import
Gargantext.Prelude
...
...
@@ -110,24 +107,6 @@ stopGargantext env = do
T
.
putStrLn
"----- Stopping gargantext -----"
runReaderT
saveRepo
env
-- | Output generated @swagger.json@ file for the @'TodoAPI'@.
swaggerWriteJSON
::
IO
()
swaggerWriteJSON
=
BL8
.
writeFile
"swagger.json"
(
encodePretty
swaggerDoc
)
-- | Swagger Specifications
swaggerDoc
::
Swagger
swaggerDoc
=
toSwagger
(
Proxy
::
Proxy
GargAPI
)
&
info
.
title
.~
"Gargantext"
&
info
.
version
.~
(
cs
$
showVersion
PG
.
version
)
-- & info.base_url ?~ (URL "http://gargantext.org/")
&
info
.
description
?~
"REST API specifications"
-- & tags .~ Set.fromList [Tag "Garg" (Just "Main perations") Nothing]
&
applyTagsFor
(
subOperations
(
Proxy
::
Proxy
GargAPI
)(
Proxy
::
Proxy
GargAPI
))
[
"Gargantext"
&
description
?~
"Main operations"
]
&
info
.
license
?~
(
"AGPLV3 (English) and CECILL (French)"
&
url
?~
URL
urlLicence
)
where
urlLicence
=
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext/blob/master/LICENSE"
{-
startGargantextMock :: PortNumber -> IO ()
startGargantextMock port = do
...
...
@@ -225,7 +204,7 @@ makeDevMiddleware mode = do
server
::
forall
env
.
EnvC
env
=>
env
->
Text
->
IO
(
Server
API
)
server
env
baseUrl
=
do
-- orchestrator <- scrapyOrchestrator env
pure
$
s
chemaUi
Server
swaggerDoc
pure
$
s
waggerSchemaUI
Server
swaggerDoc
:<|>
hoistServerWithContext
(
Proxy
::
Proxy
GargAPI
)
(
Proxy
::
Proxy
AuthContext
)
...
...
@@ -292,9 +271,6 @@ api = Proxy
apiGarg
::
Proxy
GargAPI
apiGarg
=
Proxy
---------------------------------------------------------------------
schemaUiServer
::
(
Server
api
~
Handler
Swagger
)
=>
Swagger
->
Server
(
SwaggerSchemaUI'
dir
api
)
schemaUiServer
=
swaggerSchemaUIServer
---------------------------------------------------------------------
-- Type Family for the Documentation
...
...
src/Gargantext/API/Swagger.hs
0 → 100644
View file @
8d65a86c
{-|
Module : Gargantext.API.Swagger
Description : Swagger API generation
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
---------------------------------------------------------------------
module
Gargantext.API.Swagger
where
---------------------------------------------------------------------
import
Control.Lens
import
Data.Swagger
import
Data.Version
(
showVersion
)
import
Servant
import
Servant.Swagger
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
Gargantext.API.Routes
import
Gargantext.Prelude
-- | Swagger Specifications
swaggerDoc
::
Swagger
swaggerDoc
=
toSwagger
(
Proxy
::
Proxy
GargAPI
)
&
info
.
title
.~
"Gargantext"
&
info
.
version
.~
(
cs
$
showVersion
PG
.
version
)
-- & info.base_url ?~ (URL "http://gargantext.org/")
&
info
.
description
?~
"REST API specifications"
-- & tags .~ Set.fromList [Tag "Garg" (Just "Main perations") Nothing]
&
applyTagsFor
(
subOperations
(
Proxy
::
Proxy
GargAPI
)(
Proxy
::
Proxy
GargAPI
))
[
"Gargantext"
&
description
?~
"Main operations"
]
&
info
.
license
?~
(
"AGPLV3 (English) and CECILL (French)"
&
url
?~
URL
urlLicence
)
where
urlLicence
=
"https://gitlab.iscpif.fr/gargantext/haskell-gargantext/blob/master/LICENSE"
\ No newline at end of file
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