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
144
Issues
144
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
71520f95
Commit
71520f95
authored
Nov 25, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve HasOpenApi compat shim
parent
4d824041
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
45 deletions
+37
-45
Share.hs
src/Gargantext/API/Routes/Named/Share.hs
+1
-1
Swagger.hs
src/Gargantext/API/Swagger.hs
+2
-11
OpenAPI.hs
src/Gargantext/Orphans/OpenAPI.hs
+34
-33
No files found.
src/Gargantext/API/Routes/Named/Share.hs
View file @
71520f95
...
...
@@ -29,7 +29,7 @@ import Servant
-- would fail because '#/share/NodeCorpus/16' by the RFC3968 spec is considered
-- an uriFragment, but BaseUrl cannot handle that.
newtype
ShareLink
=
ShareLink
{
getShareLink
::
URI
}
deriving
(
Show
,
Eq
,
Ord
)
deriving
(
Show
,
Eq
,
Ord
,
Generic
)
renderShareLink
::
ShareLink
->
T
.
Text
renderShareLink
=
T
.
pack
.
show
.
getShareLink
...
...
src/Gargantext/API/Swagger.hs
View file @
71520f95
...
...
@@ -17,14 +17,11 @@ module Gargantext.API.Swagger (
,
openApiDoc
)
where
---------------------------------------------------------------------
import
Control.Lens
import
Data.Swagger
import
Data.Version
(
showVersion
)
import
Servant.OpenApi
(
toOpenApi
)
import
Data.OpenApi
(
OpenApi
)
import
Servant.OpenApi
import
Data.OpenApi
import
Servant
import
Servant.Swagger
import
qualified
Paths_gargantext
as
PG
-- cabal magic build module
import
Gargantext.API.Routes.Named
qualified
as
Named
...
...
@@ -39,15 +36,9 @@ backendApiProxy = Proxy
-- is stuck on version 2.x of the OpenAPI spec.
openApiDoc
::
OpenApi
openApiDoc
=
toOpenApi
backendApiProxy
-- | Swagger Specifications
_swaggerDoc
::
Swagger
_swaggerDoc
=
toSwagger
backendApiProxy
&
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
backendApiProxy
backendApiProxy
)
[
"Gargantext"
&
description
?~
"Main operations"
]
&
info
.
license
?~
(
"AGPLV3 (English) and CECILL (French)"
&
url
?~
URL
urlLicence
)
...
...
src/Gargantext/Orphans/OpenAPI.hs
View file @
71520f95
...
...
@@ -76,13 +76,13 @@ fromParamSchema :: Swagger.ParamSchema t -> Schema
fromParamSchema
ps
=
OpenAPI
.
Schema
{
OpenAPI
.
_schemaTitle
=
Nothing
,
OpenAPI
.
_schemaDescription
=
Nothing
,
OpenAPI
.
_schemaDefault
=
Swagger
.
_paramSchemaDefault
ps
,
OpenAPI
.
_schemaDefault
=
view
Swagger
.
default_
ps
,
OpenAPI
.
_schemaExample
=
Nothing
,
OpenAPI
.
_schemaType
=
convertType
<$>
Swagger
.
_paramSchemaType
ps
,
OpenAPI
.
_schemaFormat
=
Swagger
.
_paramSchemaF
ormat
ps
,
OpenAPI
.
_schemaType
=
convertType
<$>
view
Swagger
.
type_
ps
,
OpenAPI
.
_schemaFormat
=
view
Swagger
.
f
ormat
ps
,
OpenAPI
.
_schemaNullable
=
Nothing
,
OpenAPI
.
_schemaEnum
=
Swagger
.
_paramSchemaEnum
ps
,
OpenAPI
.
_schemaMaximum
=
Swagger
.
_paramSchemaMaximum
ps
,
OpenAPI
.
_schemaEnum
=
view
Swagger
.
enum_
ps
,
OpenAPI
.
_schemaMaximum
=
view
Swagger
.
maximum_
ps
,
OpenAPI
.
_schemaExclusiveMaximum
=
Swagger
.
_paramSchemaExclusiveMaximum
ps
,
OpenAPI
.
_schemaMinimum
=
Swagger
.
_paramSchemaMinimum
ps
,
OpenAPI
.
_schemaExclusiveMinimum
=
Swagger
.
_paramSchemaExclusiveMinimum
ps
...
...
@@ -91,11 +91,11 @@ fromParamSchema ps = OpenAPI.Schema
,
OpenAPI
.
_schemaPattern
=
Swagger
.
_paramSchemaPattern
ps
,
OpenAPI
.
_schemaMaxItems
=
Swagger
.
_paramSchemaMaxItems
ps
,
OpenAPI
.
_schemaMinItems
=
Swagger
.
_paramSchemaMinItems
ps
,
OpenAPI
.
_schemaUniqueItems
=
Swagger
.
_paramSchemaU
niqueItems
ps
,
OpenAPI
.
_schemaUniqueItems
=
view
Swagger
.
u
niqueItems
ps
,
OpenAPI
.
_schemaMaxProperties
=
Nothing
,
OpenAPI
.
_schemaMinProperties
=
Nothing
,
OpenAPI
.
_schemaAdditionalProperties
=
Nothing
,
OpenAPI
.
_schemaItems
=
convertItems
<$>
Swagger
.
_paramSchemaI
tems
ps
,
OpenAPI
.
_schemaItems
=
convertItems
<$>
view
Swagger
.
i
tems
ps
,
OpenAPI
.
_schemaProperties
=
mempty
,
OpenAPI
.
_schemaRequired
=
mempty
,
OpenAPI
.
_schemaAllOf
=
Nothing
...
...
@@ -108,7 +108,7 @@ fromParamSchema ps = OpenAPI.Schema
,
OpenAPI
.
_schemaXml
=
Nothing
,
OpenAPI
.
_schemaExternalDocs
=
Nothing
,
OpenAPI
.
_schemaDeprecated
=
Nothing
,
OpenAPI
.
_schemaMultipleOf
=
Swagger
.
_paramSchemaM
ultipleOf
ps
,
OpenAPI
.
_schemaMultipleOf
=
view
Swagger
.
m
ultipleOf
ps
}
convertType
::
Swagger
.
SwaggerType
t
->
OpenAPI
.
OpenApiType
...
...
@@ -169,51 +169,52 @@ convertDiscriminator t = OpenAPI.Discriminator t mempty
fromSwaggerSchema
::
Swagger
.
Schema
->
OpenAPI
.
Schema
fromSwaggerSchema
swaggerSchema
=
OpenAPI
.
Schema
{
OpenAPI
.
_schemaTitle
=
Swagger
.
_schemaT
itle
swaggerSchema
,
OpenAPI
.
_schemaDescription
=
Swagger
.
_schemaD
escription
swaggerSchema
,
OpenAPI
.
_schemaDefault
=
Nothing
,
OpenAPI
.
_schemaExample
=
Swagger
.
_schemaE
xample
swaggerSchema
,
OpenAPI
.
_schemaType
=
Nothing
,
OpenAPI
.
_schemaFormat
=
Nothing
{
OpenAPI
.
_schemaTitle
=
view
Swagger
.
t
itle
swaggerSchema
,
OpenAPI
.
_schemaDescription
=
view
Swagger
.
d
escription
swaggerSchema
,
OpenAPI
.
_schemaDefault
=
view
Swagger
.
default_
swaggerSchema
,
OpenAPI
.
_schemaExample
=
view
Swagger
.
e
xample
swaggerSchema
,
OpenAPI
.
_schemaType
=
convertType
<$>
view
Swagger
.
type_
swaggerSchema
,
OpenAPI
.
_schemaFormat
=
view
Swagger
.
format
swaggerSchema
,
OpenAPI
.
_schemaNullable
=
Nothing
,
OpenAPI
.
_schemaEnum
=
Nothing
,
OpenAPI
.
_schemaMaximum
=
Nothing
,
OpenAPI
.
_schemaEnum
=
view
Swagger
.
enum_
swaggerSchema
,
OpenAPI
.
_schemaMaximum
=
view
Swagger
.
maximum_
swaggerSchema
,
OpenAPI
.
_schemaExclusiveMaximum
=
Nothing
,
OpenAPI
.
_schemaMinimum
=
Nothing
,
OpenAPI
.
_schemaMinimum
=
view
Swagger
.
minimum_
swaggerSchema
,
OpenAPI
.
_schemaExclusiveMinimum
=
Nothing
,
OpenAPI
.
_schemaMaxLength
=
Nothing
,
OpenAPI
.
_schemaMinLength
=
Nothing
,
OpenAPI
.
_schemaPattern
=
Nothing
,
OpenAPI
.
_schemaMaxItems
=
Nothing
,
OpenAPI
.
_schemaMinItems
=
Nothing
,
OpenAPI
.
_schemaUniqueItems
=
Nothing
,
OpenAPI
.
_schemaMaxProperties
=
Swagger
.
_schemaM
axProperties
swaggerSchema
,
OpenAPI
.
_schemaMinProperties
=
Swagger
.
_schemaM
inProperties
swaggerSchema
,
OpenAPI
.
_schemaAdditionalProperties
=
convertAdditionalProps
<$>
Swagger
.
_schemaA
dditionalProperties
swaggerSchema
,
OpenAPI
.
_schemaItems
=
Nothing
,
OpenAPI
.
_schemaProperties
=
HM
.
map
convertRef
$
Swagger
.
_schemaP
roperties
swaggerSchema
,
OpenAPI
.
_schemaRequired
=
Swagger
.
_schemaR
equired
swaggerSchema
,
OpenAPI
.
_schemaAllOf
=
map
convertRef
<$>
Swagger
.
_schemaA
llOf
swaggerSchema
,
OpenAPI
.
_schemaUniqueItems
=
view
Swagger
.
uniqueItems
swaggerSchema
,
OpenAPI
.
_schemaMaxProperties
=
view
Swagger
.
m
axProperties
swaggerSchema
,
OpenAPI
.
_schemaMinProperties
=
view
Swagger
.
m
inProperties
swaggerSchema
,
OpenAPI
.
_schemaAdditionalProperties
=
convertAdditionalProps
<$>
view
Swagger
.
a
dditionalProperties
swaggerSchema
,
OpenAPI
.
_schemaItems
=
convertItems
<$>
view
Swagger
.
items
swaggerSchema
,
OpenAPI
.
_schemaProperties
=
HM
.
map
convertRef
$
view
Swagger
.
p
roperties
swaggerSchema
,
OpenAPI
.
_schemaRequired
=
view
Swagger
.
r
equired
swaggerSchema
,
OpenAPI
.
_schemaAllOf
=
map
convertRef
<$>
view
Swagger
.
a
llOf
swaggerSchema
,
OpenAPI
.
_schemaOneOf
=
Nothing
,
OpenAPI
.
_schemaNot
=
Nothing
,
OpenAPI
.
_schemaAnyOf
=
Nothing
,
OpenAPI
.
_schemaDiscriminator
=
convertDiscriminator
<$>
Swagger
.
_schemaD
iscriminator
swaggerSchema
,
OpenAPI
.
_schemaReadOnly
=
Swagger
.
_schemaR
eadOnly
swaggerSchema
,
OpenAPI
.
_schemaDiscriminator
=
convertDiscriminator
<$>
view
Swagger
.
d
iscriminator
swaggerSchema
,
OpenAPI
.
_schemaReadOnly
=
view
Swagger
.
r
eadOnly
swaggerSchema
,
OpenAPI
.
_schemaWriteOnly
=
Nothing
,
OpenAPI
.
_schemaXml
=
convertXml
<$>
Swagger
.
_schemaX
ml
swaggerSchema
,
OpenAPI
.
_schemaExternalDocs
=
convertDocs
<$>
Swagger
.
_schemaE
xternalDocs
swaggerSchema
,
OpenAPI
.
_schemaXml
=
convertXml
<$>
view
Swagger
.
x
ml
swaggerSchema
,
OpenAPI
.
_schemaExternalDocs
=
convertDocs
<$>
view
Swagger
.
e
xternalDocs
swaggerSchema
,
OpenAPI
.
_schemaDeprecated
=
Nothing
,
OpenAPI
.
_schemaMultipleOf
=
Nothing
,
OpenAPI
.
_schemaMultipleOf
=
view
Swagger
.
multipleOf
swaggerSchema
}
-- little compat-shim to avoid re-implementing 'ToSchema' and 'ToParamSchema' for each
-- and every type, while we transition away from swagger.
instance
{-# OVERLAP
PABLE #-}
Swagger
.
ToParamSchema
a
=>
ToParamSchema
a
where
instance
{-# OVERLAP
S #-}
(
Typeable
a
,
Swagger
.
ToParamSchema
a
)
=>
ToParamSchema
a
where
toParamSchema
p
=
fromParamSchema
$
Swagger
.
toParamSchema
p
instance
{-# OVERLAPPABLE #-}
(
Typeable
a
,
Swagger
.
ToSchema
a
)
=>
ToSchema
a
where
declareNamedSchema
_
=
pure
$
OpenAPI
.
NamedSchema
swaggerName
openApiSchema
instance
{-# OVERLAPS #-}
(
Typeable
a
,
Swagger
.
ToSchema
a
)
=>
ToSchema
a
where
declareNamedSchema
_
=
pure
$
OpenAPI
.
NamedSchema
swaggerName
openApiSchema
where
Swagger
.
NamedSchema
swaggerName
swaggerSchema
=
Swagger
.
toNamedSchema
(
Proxy
::
Proxy
a
)
openApiSchema
=
fromSwaggerSchema
swaggerSchema
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