Skip to content

Commit 39fb875

Browse files
committed
moving servant-swagger into the main servant repo
1 parent efffc70 commit 39fb875

30 files changed

+2551
-0
lines changed

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packages:
1212
servant-docs/
1313
servant-foreign/
1414
servant-server/
15+
servant-swagger/
1516
doc/tutorial/
1617

1718
-- servant streaming

servant-swagger/.travis.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# This Travis job script has been generated by a script via
2+
#
3+
# haskell-ci '--config=cabal.haskell-ci' 'cabal.project'
4+
#
5+
# To regenerate the script (for example after adjusting tested-with) run
6+
#
7+
# haskell-ci regenerate
8+
#
9+
# For more information, see https://github.com/haskell-CI/haskell-ci
10+
#
11+
# version: 0.10.3
12+
#
13+
version: ~> 1.0
14+
language: c
15+
os: linux
16+
dist: xenial
17+
git:
18+
# whether to recursively clone submodules
19+
submodules: false
20+
branches:
21+
only:
22+
- master
23+
cache:
24+
directories:
25+
- $HOME/.cabal/packages
26+
- $HOME/.cabal/store
27+
- $HOME/.hlint
28+
before_cache:
29+
- rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
30+
# remove files that are regenerated by 'cabal update'
31+
- rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
32+
- rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
33+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
34+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
35+
- rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
36+
- rm -rfv $CABALHOME/packages/head.hackage
37+
jobs:
38+
include:
39+
- compiler: ghc-8.10.2
40+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.2","cabal-install-3.2"]}}
41+
os: linux
42+
- compiler: ghc-8.8.4
43+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.4","cabal-install-3.2"]}}
44+
os: linux
45+
- compiler: ghc-8.6.5
46+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}}
47+
os: linux
48+
- compiler: ghc-8.4.4
49+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.2"]}}
50+
os: linux
51+
- compiler: ghc-8.2.2
52+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.2"]}}
53+
os: linux
54+
- compiler: ghc-8.0.2
55+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.2"]}}
56+
os: linux
57+
before_install:
58+
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
59+
- WITHCOMPILER="-w $HC"
60+
- HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')
61+
- HCPKG="$HC-pkg"
62+
- unset CC
63+
- CABAL=/opt/ghc/bin/cabal
64+
- CABALHOME=$HOME/.cabal
65+
- export PATH="$CABALHOME/bin:$PATH"
66+
- TOP=$(pwd)
67+
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
68+
- echo $HCNUMVER
69+
- CABAL="$CABAL -vnormal+nowrap"
70+
- set -o pipefail
71+
- TEST=--enable-tests
72+
- BENCH=--enable-benchmarks
73+
- HEADHACKAGE=false
74+
- rm -f $CABALHOME/config
75+
- |
76+
echo "verbose: normal +nowrap +markoutput" >> $CABALHOME/config
77+
echo "remote-build-reporting: anonymous" >> $CABALHOME/config
78+
echo "write-ghc-environment-files: always" >> $CABALHOME/config
79+
echo "remote-repo-cache: $CABALHOME/packages" >> $CABALHOME/config
80+
echo "logs-dir: $CABALHOME/logs" >> $CABALHOME/config
81+
echo "world-file: $CABALHOME/world" >> $CABALHOME/config
82+
echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
83+
echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
84+
echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
85+
echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
86+
echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
87+
echo "install-dirs user" >> $CABALHOME/config
88+
echo " prefix: $CABALHOME" >> $CABALHOME/config
89+
echo "repository hackage.haskell.org" >> $CABALHOME/config
90+
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
91+
install:
92+
- ${CABAL} --version
93+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
94+
- |
95+
echo "program-default-options" >> $CABALHOME/config
96+
echo " ghc-options: $GHCJOBS +RTS -M6G -RTS" >> $CABALHOME/config
97+
- cat $CABALHOME/config
98+
- rm -fv cabal.project cabal.project.local cabal.project.freeze
99+
- travis_retry ${CABAL} v2-update -v
100+
# Generate cabal.project
101+
- rm -rf cabal.project cabal.project.local cabal.project.freeze
102+
- touch cabal.project
103+
- |
104+
echo "packages: ." >> cabal.project
105+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package servant-swagger' >> cabal.project ; fi
106+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
107+
- |
108+
echo "allow-newer: aeson-pretty-0.8.7:base-compat" >> cabal.project
109+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-swagger)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
110+
- cat cabal.project || true
111+
- cat cabal.project.local || true
112+
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
113+
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
114+
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
115+
- rm cabal.project.freeze
116+
- travis_wait 40 ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all
117+
- travis_wait 40 ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --dep -j2 all
118+
script:
119+
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
120+
# Packaging...
121+
- ${CABAL} v2-sdist all
122+
# Unpacking...
123+
- mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
124+
- cd ${DISTDIR} || false
125+
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;
126+
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
127+
- PKGDIR_servant_swagger="$(find . -maxdepth 1 -type d -regex '.*/servant-swagger-[0-9.]*')"
128+
# Generate cabal.project
129+
- rm -rf cabal.project cabal.project.local cabal.project.freeze
130+
- touch cabal.project
131+
- |
132+
echo "packages: ${PKGDIR_servant_swagger}" >> cabal.project
133+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package servant-swagger' >> cabal.project ; fi
134+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
135+
- |
136+
echo "allow-newer: aeson-pretty-0.8.7:base-compat" >> cabal.project
137+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(servant-swagger)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
138+
- cat cabal.project || true
139+
- cat cabal.project.local || true
140+
# Building...
141+
# this builds all libraries and executables (without tests/benchmarks)
142+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
143+
# Building with tests and benchmarks...
144+
# build & run tests, build benchmarks
145+
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
146+
# Testing...
147+
- ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all
148+
# cabal check...
149+
- (cd ${PKGDIR_servant_swagger} && ${CABAL} -vnormal check)
150+
# haddock...
151+
- ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all
152+
# Building without installed constraints for packages in global-db...
153+
- rm -f cabal.project.local
154+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks all
155+
# Constraint sets
156+
- rm -rf cabal.project.local
157+
# Constraint set swagger2-2.3
158+
- if [ $HCNUMVER -lt 80800 ] ; then ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.3.*' all ; fi
159+
# Constraint set swagger2-2.4
160+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.4.*' all
161+
# Constraint set swagger2-2.5
162+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='swagger2 ==2.5.*' all
163+
# Constraint set servant-0.18.1
164+
- ${CABAL} v2-build $WITHCOMPILER --disable-tests --disable-benchmarks --constraint='servant == 0.18.1' all
165+
166+
# REGENDATA ("0.10.3",["--config=cabal.haskell-ci","cabal.project"])
167+
# EOF

servant-swagger/CHANGELOG.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
1.1.9
2+
-------
3+
4+
* Support `servant-0.18`
5+
6+
1.1.8
7+
-------
8+
9+
* Support `servant-0.17`
10+
11+
1.1.7.1
12+
-------
13+
14+
* Support `swagger2-2.4`
15+
16+
1.1.7
17+
-----
18+
19+
* Support servant-0.15
20+
- support for 'Stream' and 'StreamBody' combinators
21+
- orphan 'ToSchema (SourceT m a)' instance
22+
* Fix BodyTypes to work with generalized ReqBody'
23+
[#88](https://github.com/haskell-servant/servant-swagger/pull/88)
24+
25+
1.1.6
26+
-----
27+
28+
* Fixes:
29+
* `validateEveryToJSON` now prints validation errors
30+
31+
* Notes:
32+
* GHC-8.6 compatible release
33+
34+
1.1.5
35+
-----
36+
37+
* Notes:
38+
* `servant-0.13` compatible release
39+
* Drops compatibility with previous `servant` versions.
40+
41+
1.1.4
42+
-----
43+
44+
* Notes:
45+
* `servant-0.12` compatible release
46+
47+
1.1.3.1
48+
---
49+
50+
* Notes:
51+
* GHC-8.2 compatible release
52+
53+
1.1.3
54+
---
55+
56+
* Notes:
57+
* `servant-0.11` compatible release
58+
59+
1.1.2.1
60+
---
61+
62+
* Notes:
63+
* `servant-0.10` compatible release
64+
65+
1.1.2
66+
---
67+
68+
* Minor fixes:
69+
* Support for aeson-1, insert-ordered-containers-0.2
70+
* CaptureAll instance
71+
72+
1.1.1
73+
---
74+
75+
* Minor fixes:
76+
* Fix `unused-imports` and `unused-foralls` warnings;
77+
* Fix tests to match `swagger2-2.1.1` (add `example` property for `UTCTime` schema).
78+
79+
1.1
80+
---
81+
82+
* Breaking changes:
83+
* Requires `swagger2 >= 2.1`
84+
* Requires `servant >= 0.5`
85+
86+
* Notes:
87+
* GHC-8.0 compatible release
88+
89+
1.0.3
90+
---
91+
92+
* Fixes:
93+
* Improve compile-time performance of `BodyTypes` even further (see [18e0d95](https://github.com/haskell-servant/servant-swagger/commit/18e0d95ef6fe9076dd9621cb515d8d1a189f71d3))!
94+
95+
1.0.2
96+
---
97+
98+
* Minor changes:
99+
* Add GHC 7.8 support (see [#26](https://github.com/haskell-servant/servant-swagger/pull/26)).
100+
101+
* Fixes:
102+
* Improve compile-time performance of `BodyTypes` (see [#25](https://github.com/haskell-servant/servant-swagger/issues/25)).
103+
104+
1.0.1
105+
---
106+
107+
* Fixes:
108+
* Stop using `Data.Swagger.Internal`;
109+
* Documentation fixes (links to examples).
110+
111+
1.0
112+
---
113+
114+
* Major changes (see [#24](https://github.com/haskell-servant/servant-swagger/pull/24)):
115+
* Switch to `swagger2-2.*`;
116+
* Add automatic `ToJSON`/`ToSchema` validation tests;
117+
* Add great documentation;
118+
* Export some type-level functions for servant API.
119+
120+
* Minor changes:
121+
* Rework Todo API example;
122+
* Stop exporting `ToResponseHeader`, `AllAccept` and `AllToResponseHeader` (see [bd50db4](https://github.com/haskell-servant/servant-swagger/commit/bd50db48ca6a106e4366560ded70932d409de1e2));
123+
* Change maintainer, update authors/copyrights (see [1a62681](https://github.com/haskell-servant/servant-swagger/commit/1a6268101dc826a92c42e832e402e251c0d32147));
124+
* Include changelog and example files into `extra-source-files`.
125+
126+
0.1.2
127+
---
128+
129+
* Fixes:
130+
* Fix default spec for `ReqBody` param to be required (see [#22](https://github.com/haskell-servant/servant-swagger/issues/22));
131+
* Set version bounds for `swagger2`.
132+
133+
0.1.1
134+
---
135+
136+
* Fixes:
137+
* Fix `subOperations` to filter endpoints also by method (see [#18](https://github.com/haskell-servant/servant-swagger/issues/18));
138+
* Fix response schema in `ToSwagger` instance for `Header` (see [b59e557](https://github.com/haskell-servant/servant-swagger/commit/b59e557a05bc2669332c52b397879e7598747b82)).
139+
140+
0.1
141+
---
142+
* Major changes
143+
* Use `swagger2` for data model (see [#9](https://github.com/dmjio/servant-swagger/pull/9)); this changes almost everything.

servant-swagger/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2015-2016, Servant contributors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of servant-swagger nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+

servant-swagger/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# servant-swagger
2+
3+
[![Build Status](https://travis-ci.org/haskell-servant/servant-swagger.svg?branch=master)](https://travis-ci.org/haskell-servant/servant-swagger)
4+
[![Hackage](https://img.shields.io/hackage/v/servant-swagger.svg)](http://hackage.haskell.org/package/servant-swagger)
5+
[![Stackage LTS](http://stackage.org/package/servant-swagger/badge/lts)](http://stackage.org/lts/package/servant-swagger)
6+
[![Stackage Nightly](http://stackage.org/package/servant-swagger/badge/nightly)](http://stackage.org/nightly/package/servant-swagger)
7+
8+
Swagger 2.0 conforming json for [servant](https://github.com/haskell-servant/servant) APIs.
9+
10+
![servant-swagger robot](http://s16.postimg.org/rndz1wbyt/servant.png)
11+
12+
### Motivation
13+
14+
Swagger is a project used to describe and document RESTful APIs.
15+
Unlike Servant it is language-agnostic and thus is quite popular among developers
16+
in different languages. It also exists for a longer time and has more tools to work with.
17+
18+
This package provides means to generate Swagger specification for a Servant API
19+
and also to partially test whether API conforms with its specification.
20+
21+
Generated Swagger specification then can be used for many things such as
22+
- displaying interactive documentation using [Swagger UI](http://swagger.io/swagger-ui/);
23+
- generating clients and servers in many languages using [Swagger Codegen](http://swagger.io/swagger-codegen/);
24+
- and [many others](http://swagger.io/open-source-integrations/).
25+
26+
### Usage
27+
28+
Please refer to [haddock documentation](http://hackage.haskell.org/package/servant-swagger).
29+
30+
Some examples can be found in [`example/` directory](/example).
31+
32+
### Try it out
33+
34+
All generated swagger specifications can be interactively viewed on [Swagger Editor](http://editor.swagger.io/).
35+
36+
Ready-to-use specification can be served as JSON and interactive API documentation
37+
can be displayed using [Swagger UI](https://github.com/swagger-api/swagger-ui).
38+
39+
Many Swagger tools, including server and client code generation for many languages, can be found on
40+
[Swagger's Tools and Integrations page](http://swagger.io/open-source-integrations/).
41+
42+
### Contributing
43+
44+
We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.
45+
46+
Please report bugs via the [github issue tracker](https://github.com/haskell-servant/servant-swagger/issues).
47+

0 commit comments

Comments
 (0)