Skip to content

Commit be1dd4c

Browse files
authored
Merge pull request #115 from haskell-servant/servant-0.17
Support servant-0.17
2 parents 6d090e5 + 45f6820 commit be1dd4c

File tree

5 files changed

+60
-72
lines changed

5 files changed

+60
-72
lines changed

.travis.yml

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# For more information, see https://github.com/haskell-CI/haskell-ci
66
#
7-
# version: 0.9.20191209
7+
# version: 0.9.20200121
88
#
99
version: ~> 1.0
1010
language: c
@@ -59,57 +59,31 @@ before_install:
5959
- TOP=$(pwd)
6060
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
6161
- echo $HCNUMVER
62-
- CABAL="$CABAL -vnormal+nowrap+markoutput"
62+
- CABAL="$CABAL -vnormal+nowrap"
6363
- set -o pipefail
64-
- |
65-
echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
66-
echo 'BEGIN { state = "output"; }' >> .colorful.awk
67-
echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
68-
echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
69-
echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
70-
echo ' if (state == "cabal") {' >> .colorful.awk
71-
echo ' print blue($0)' >> .colorful.awk
72-
echo ' } else {' >> .colorful.awk
73-
echo ' print $0' >> .colorful.awk
74-
echo ' }' >> .colorful.awk
75-
echo '}' >> .colorful.awk
76-
- cat .colorful.awk
77-
- |
78-
color_cabal_output () {
79-
awk -f $TOP/.colorful.awk
80-
}
81-
- echo text | color_cabal_output
82-
install:
83-
- ${CABAL} --version
84-
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
8564
- TEST=--enable-tests
8665
- BENCH=--enable-benchmarks
8766
- HEADHACKAGE=false
8867
- rm -f $CABALHOME/config
8968
- |
90-
echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
91-
echo "remote-build-reporting: anonymous" >> $CABALHOME/config
92-
echo "write-ghc-environment-files: always" >> $CABALHOME/config
93-
echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
94-
echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
95-
echo "world-file: $CABALHOME/world" >> $CABALHOME/config
96-
echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
97-
echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
98-
echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
99-
echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
100-
echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
101-
echo "install-dirs user" >> $CABALHOME/config
102-
echo " prefix: $CABALHOME" >> $CABALHOME/config
103-
echo "repository hackage.haskell.org" >> $CABALHOME/config
104-
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
105-
echo " secure: True" >> $CABALHOME/config
106-
echo " key-threshold: 3" >> $CABALHOME/config
107-
echo " root-keys:" >> $CABALHOME/config
108-
echo " fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0" >> $CABALHOME/config
109-
echo " 1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42" >> $CABALHOME/config
110-
echo " 2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3" >> $CABALHOME/config
111-
echo " 0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d" >> $CABALHOME/config
112-
echo " 51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921" >> $CABALHOME/config
69+
echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
70+
echo "remote-build-reporting: anonymous" >> $CABALHOME/config
71+
echo "write-ghc-environment-files: always" >> $CABALHOME/config
72+
echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
73+
echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
74+
echo "world-file: $CABALHOME/world" >> $CABALHOME/config
75+
echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
76+
echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
77+
echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
78+
echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
79+
echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
80+
echo "install-dirs user" >> $CABALHOME/config
81+
echo " prefix: $CABALHOME" >> $CABALHOME/config
82+
echo "repository hackage.haskell.org" >> $CABALHOME/config
83+
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
84+
install:
85+
- ${CABAL} --version
86+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
11387
- |
11488
echo "program-default-options" >> $CABALHOME/config
11589
echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
@@ -127,15 +101,15 @@ install:
127101
- cat cabal.project || true
128102
- cat cabal.project.local || true
129103
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
130-
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
104+
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
131105
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
132106
- rm cabal.project.freeze
133-
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output
134-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all | color_cabal_output
107+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
108+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
135109
script:
136110
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
137111
# Packaging...
138-
- ${CABAL} v2-sdist all | color_cabal_output
112+
- ${CABAL} v2-sdist all
139113
# Unpacking...
140114
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
141115
- cd ${DISTDIR} || false
@@ -154,31 +128,29 @@ script:
154128
- cat cabal.project.local || true
155129
# Building...
156130
# this builds all libraries and executables (without tests/benchmarks)
157-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
131+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
158132
# Building with tests and benchmarks...
159133
# build & run tests, build benchmarks
160-
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
134+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
161135
# Testing...
162-
- ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
136+
- ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
163137
# cabal check...
164138
- (cd ${PKGDIR_servant_swagger} && ${CABAL} -vnormal check)
165139
# haddock...
166-
- ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output
140+
- ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
167141
# Building without installed constraints for packages in global-db...
168142
- rm -f cabal.project.local
169-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all | color_cabal_output
143+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
170144
# Constraint sets
171145
- rm -rf cabal.project.local
172146
# Constraint set swagger2-2.3
173-
- if [ $HCNUMVER -lt 80800 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.3.*' all | color_cabal_output ; fi
147+
- if [ $HCNUMVER -lt 80800 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.3.*' all ; fi
174148
# Constraint set swagger2-2.4
175-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.4.*' all | color_cabal_output
149+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.4.*' all
176150
# Constraint set swagger2-2.5
177-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.5.*' all | color_cabal_output
178-
# Constraint set servant-0.15
179-
- if [ $HCNUMVER -lt 80800 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='servant == 0.15.*' all | color_cabal_output ; fi
180-
# Constraint set servant-0.16
181-
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='servant == 0.16.*' all | color_cabal_output
151+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.5.*' all
152+
# Constraint set servant-0.17
153+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='servant == 0.17.*' all
182154

183-
# REGENDATA ("0.9.20191209",["--config=cabal.haskell-ci","cabal.project"])
155+
# REGENDATA ("0.9.20200121",["--config=cabal.haskell-ci","cabal.project"])
184156
# EOF

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.1.8
2+
-------
3+
4+
* Support `servant-0.17`
5+
16
1.1.7.1
27
-------
38

cabal.haskell-ci

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,5 @@ constraint-set swagger2-2.4
1010
constraint-set swagger2-2.5
1111
constraints: swagger2 ==2.5.*
1212

13-
constraint-set servant-0.15
14-
ghc: <8.8
15-
constraints: servant == 0.15.*
16-
17-
constraint-set servant-0.16
18-
constraints: servant == 0.16.*
13+
constraint-set servant-0.17
14+
constraints: servant == 0.17.*

servant-swagger.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: servant-swagger
2-
version: 1.1.7.1
3-
x-revision: 2
2+
version: 1.1.8
43
synopsis: Generate a Swagger/OpenAPI/OAS 2.0 specification for your servant API.
54
description:
65
Swagger is a project used to describe and document RESTful APIs. The core of the
@@ -83,7 +82,7 @@ library
8382
, http-media >=0.7.1.3 && <0.9
8483
, insert-ordered-containers >=0.2.1.0 && <0.3
8584
, lens >=4.17 && <4.19
86-
, servant >=0.15 && <0.17
85+
, servant >=0.17 && <0.18
8786
, singleton-bool >=0.1.4 && <0.2
8887
, swagger2 >=2.3.0.1 && <2.6
8988
, text >=1.2.3.0 && <1.3

src/Servant/Swagger/Internal.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ mkEndpointWithSchemaRef mref path _ = mempty
130130
responseContentTypes = allContentType (Proxy :: Proxy cs)
131131
responseHeaders = toAllResponseHeaders (Proxy :: Proxy hs)
132132

133+
mkEndpointNoContentVerb :: forall proxy method.
134+
(SwaggerMethod method)
135+
=> FilePath -- ^ Endpoint path.
136+
-> proxy (NoContentVerb method) -- ^ Method
137+
-> Swagger
138+
mkEndpointNoContentVerb path _ = mempty
139+
& paths.at path ?~
140+
(mempty & method ?~ (mempty
141+
& at code ?~ Inline mempty))
142+
where
143+
method = swaggerMethod (Proxy :: Proxy method)
144+
code = 204 -- hardcoded in servant-server
145+
133146
-- | Add parameter to every operation in the spec.
134147
addParam :: Param -> Swagger -> Swagger
135148
addParam param = allOperations.parameters %~ (Inline param :)
@@ -192,6 +205,9 @@ instance (AllAccept cs, AllToResponseHeader hs, KnownNat status, SwaggerMethod m
192205
=> HasSwagger (Verb method status cs (Headers hs NoContent)) where
193206
toSwagger = mkEndpointNoContent "/"
194207

208+
instance (SwaggerMethod method) => HasSwagger (NoContentVerb method) where
209+
toSwagger = mkEndpointNoContentVerb "/"
210+
195211
instance (HasSwagger a, HasSwagger b) => HasSwagger (a :<|> b) where
196212
toSwagger _ = toSwagger (Proxy :: Proxy a) <> toSwagger (Proxy :: Proxy b)
197213

0 commit comments

Comments
 (0)