Skip to content

Commit a65e7a5

Browse files
committed
Update example, add to CI
1 parent 647e717 commit a65e7a5

File tree

6 files changed

+141
-122
lines changed

6 files changed

+141
-122
lines changed

.travis.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,21 @@ install:
9090
- touch cabal.project
9191
- |
9292
echo "packages: ." >> cabal.project
93+
echo "packages: example" >> cabal.project
9394
- echo 'package servant-openapi3' >> cabal.project
9495
- "echo ' ghc-options: -Werror=missing-methods' >> cabal.project"
96+
- echo 'package example' >> cabal.project
97+
- "echo ' ghc-options: -Werror=missing-methods' >> cabal.project"
9598
- |
9699
echo "source-repository-package" >> cabal.project
97100
echo " type: git" >> cabal.project
98101
echo " location: https://github.com/biocad/openapi3/" >> cabal.project
99102
echo " tag: bd9df532f2381c4b22fe86ef722715088f5cfa68" >> cabal.project
100-
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-openapi3)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
103+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(example|servant-openapi3)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
101104
- cat cabal.project || true
102105
- cat cabal.project.local || true
103106
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
107+
- if [ -f "example/configure.ac" ]; then (cd "example" && autoreconf -i); fi
104108
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
105109
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
106110
- rm cabal.project.freeze
@@ -116,19 +120,23 @@ script:
116120
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
117121
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
118122
- PKGDIR_servant_openapi3="$(find . -maxdepth 1 -type d -regex '.*/servant-openapi3-[0-9.]*')"
123+
- PKGDIR_example="$(find . -maxdepth 1 -type d -regex '.*/example-[0-9.]*')"
119124
# Generate cabal.project
120125
- rm -rf cabal.project cabal.project.local cabal.project.freeze
121126
- touch cabal.project
122127
- |
123128
echo "packages: ${PKGDIR_servant_openapi3}" >> cabal.project
129+
echo "packages: ${PKGDIR_example}" >> cabal.project
124130
- echo 'package servant-openapi3' >> cabal.project
125131
- "echo ' ghc-options: -Werror=missing-methods' >> cabal.project"
132+
- echo 'package example' >> cabal.project
133+
- "echo ' ghc-options: -Werror=missing-methods' >> cabal.project"
126134
- |
127135
echo "source-repository-package" >> cabal.project
128136
echo " type: git" >> cabal.project
129137
echo " location: https://github.com/biocad/openapi3/" >> cabal.project
130138
echo " tag: bd9df532f2381c4b22fe86ef722715088f5cfa68" >> cabal.project
131-
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-openapi3)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
139+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(example|servant-openapi3)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
132140
- cat cabal.project || true
133141
- cat cabal.project.local || true
134142
# Building...
@@ -141,6 +149,7 @@ script:
141149
- ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
142150
# cabal check...
143151
- (cd ${PKGDIR_servant_openapi3} && ${CABAL} -vnormal check)
152+
- (cd ${PKGDIR_example} && ${CABAL} -vnormal check)
144153
# haddock...
145154
- ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
146155
# Building without installed constraints for packages in global-db...

cabal.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
packages:
2-
servant-openapi3.cabal
2+
servant-openapi3.cabal,
3+
example/example.cabal
34
tests: true
45

56
source-repository-package

example/example.cabal

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
name: example
22
version: 1.0
3-
synopsis: servant-swagger demonstration
4-
description: servant-swagger demonstration
3+
synopsis: servant-openapi3 demonstration
4+
description: servant-openapi3 demonstration
55
license: BSD3
66
license-file: LICENSE
77
author: David Johnson, Nickolay Kudasov
88
maintainer: [email protected]
9-
copyright: (c) 2015-2016, Servant contributors
9+
copyright: (c) 2015-2020, Servant contributors
1010
category: Web
1111
build-type: Simple
1212
cabal-version: >=1.10
1313
data-files:
1414
swagger.json
1515

16+
tested-with:
17+
GHC ==8.4.4
18+
|| ==8.6.5
19+
|| ==8.8.3
20+
1621
library
1722
ghc-options: -Wall
1823
hs-source-dirs: src/
@@ -25,8 +30,8 @@ library
2530
, lens
2631
, servant
2732
, servant-server
28-
, servant-swagger
29-
, swagger2
33+
, servant-openapi3
34+
, openapi3
3035
, text
3136
, time
3237
default-language: Haskell2010
@@ -55,7 +60,7 @@ test-suite swagger-server-spec
5560
, bytestring
5661
, example
5762
, hspec
58-
, servant-swagger
63+
, servant-openapi3
5964
, QuickCheck
6065
, quickcheck-instances
6166
default-language: Haskell2010

example/src/Todo.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import Control.Lens
1010
import Data.Aeson
1111
import Data.Aeson.Encode.Pretty (encodePretty)
1212
import qualified Data.ByteString.Lazy.Char8 as BL8
13+
import Data.OpenApi hiding (Server)
1314
import Data.Proxy
14-
import Data.Swagger
1515
import Data.Text (Text)
1616
import Data.Time (UTCTime (..), fromGregorian)
1717
import Data.Typeable (Typeable)
1818
import GHC.Generics
1919
import Servant
20-
import Servant.Swagger
20+
import Servant.OpenApi
2121

2222
todoAPI :: Proxy TodoAPI
2323
todoAPI = Proxy
@@ -30,7 +30,7 @@ type TodoAPI
3030
:<|> "todo" :> Capture "id" TodoId :> ReqBody '[JSON] Todo :> Put '[JSON] TodoId
3131

3232
-- | API for serving @swagger.json@.
33-
type SwaggerAPI = "swagger.json" :> Get '[JSON] Swagger
33+
type SwaggerAPI = "swagger.json" :> Get '[JSON] OpenApi
3434

3535
-- | Combined API of a Todo service with Swagger documentation.
3636
type API = SwaggerAPI :<|> TodoAPI
@@ -57,8 +57,8 @@ instance ToParamSchema TodoId
5757
instance ToSchema TodoId
5858

5959
-- | Swagger spec for Todo API.
60-
todoSwagger :: Swagger
61-
todoSwagger = toSwagger todoAPI
60+
todoSwagger :: OpenApi
61+
todoSwagger = toOpenApi todoAPI
6262
& info.title .~ "Todo API"
6363
& info.version .~ "1.0"
6464
& info.description ?~ "This is an API that tests swagger integration"

0 commit comments

Comments
 (0)