Skip to content

Commit

Permalink
Merge pull request #1475 from akhesaCaro/aeson_2
Browse files Browse the repository at this point in the history
support Aeson 2
  • Loading branch information
akhesaCaro committed Nov 26, 2021
2 parents 3ed24fd + 05ef0dd commit 9a39799
Show file tree
Hide file tree
Showing 35 changed files with 2,382 additions and 16 deletions.
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ packages:
servant-docs/
servant-foreign/
servant-server/
servant-swagger/
doc/tutorial/

-- servant streaming
Expand Down
4 changes: 2 additions & 2 deletions servant-auth/servant-auth-client/servant-auth-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test-suite spec
build-depends:
hspec >= 2.5.5 && < 2.9
, QuickCheck >= 2.11.3 && < 2.15
, aeson >= 1.3.1.1 && < 1.6
, aeson >= 1.3.1.1 && < 3
, bytestring >= 0.10.6.0 && < 0.11
, http-client >= 0.5.13.1 && < 0.8
, http-types >= 0.12.2 && < 0.13
Expand All @@ -74,7 +74,7 @@ test-suite spec
, transformers >= 0.4.2.0 && < 0.6
, wai >= 3.2.1.2 && < 3.3
, warp >= 3.2.25 && < 3.4
, jose >= 0.7.0.0 && < 0.9
, jose >= 0.7.0.0 && < 0.10
other-modules:
Servant.Auth.ClientSpec
default-language: Haskell2010
6 changes: 3 additions & 3 deletions servant-auth/servant-auth-server/servant-auth-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ library
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.16
, aeson >= 1.3.1.1 && < 1.6
, base64-bytestring >= 1.0.0.1 && < 1.3
, aeson >= 1.0.0.1 && < 3
, base64-bytestring >= 1.0.0.1 && < 2
, blaze-builder >= 0.4.1.0 && < 0.5
, bytestring >= 0.10.6.0 && < 0.11
, case-insensitive >= 1.2.0.11 && < 1.3
, cookie >= 0.4.4 && < 0.5
, data-default-class >= 0.1.2.0 && < 0.2
, entropy >= 0.4.1.3 && < 0.5
, http-types >= 0.12.2 && < 0.13
, jose >= 0.7.0.0 && < 0.9
, jose >= 0.7.0.0 && < 0.10
, lens >= 4.16.1 && < 5.1
, memory >= 0.14.16 && < 0.17
, monad-time >= 0.3.1.0 && < 0.4
Expand Down
4 changes: 2 additions & 2 deletions servant-auth/servant-auth-swagger/servant-auth-swagger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ library
build-depends:
base >= 4.10 && < 4.16
, text >= 1.2.3.0 && < 1.3
, servant-swagger >= 1.1.5 && < 1.8
, swagger2 >= 2.2.2 && < 2.7
, servant-swagger >= 1.1.5 && < 2
, swagger2 >= 2.2.2 && < 3
, servant >= 0.13 && < 0.19
, servant-auth == 0.4.*
, lens >= 4.16.1 && < 5.1
Expand Down
5 changes: 3 additions & 2 deletions servant-auth/servant-auth/servant-auth.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ library
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.16
, aeson >= 1.3.1.1 && < 1.6
, jose >= 0.7.0.0 && < 0.9
, containers >= 0.6 && < 0.7
, aeson >= 1.3.1.1 && < 3
, jose >= 0.7.0.0 && < 0.10
, lens >= 4.16.1 && < 5.1
, servant >= 0.15 && < 0.19
, text >= 1.2.3.0 && < 1.3
Expand Down
11 changes: 9 additions & 2 deletions servant-auth/servant-auth/src/Servant/Auth/JWT.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{-# LANGUAGE CPP #-}

module Servant.Auth.JWT where

import Control.Lens ((^.))
import qualified Crypto.JWT as Jose
import Data.Aeson (FromJSON, Result (..), ToJSON, fromJSON,
toJSON)
import qualified Data.HashMap.Strict as HM
#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Map as KM
#else
import qualified Data.HashMap.Strict as KM
#endif

import qualified Data.Text as T


Expand All @@ -17,7 +24,7 @@ import qualified Data.Text as T
class FromJWT a where
decodeJWT :: Jose.ClaimsSet -> Either T.Text a
default decodeJWT :: FromJSON a => Jose.ClaimsSet -> Either T.Text a
decodeJWT m = case HM.lookup "dat" (m ^. Jose.unregisteredClaims) of
decodeJWT m = case KM.lookup "dat" (m ^. Jose.unregisteredClaims) of
Nothing -> Left "Missing 'dat' claim"
Just v -> case fromJSON v of
Error e -> Left $ T.pack e
Expand Down
2 changes: 1 addition & 1 deletion servant-client-core/servant-client-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ library
-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
-- Here can be exceptions if we really need features from the newer versions.
build-depends:
aeson >= 1.4.1.0 && < 1.6
aeson >= 1.4.1.0 && < 3
, base-compat >= 0.10.5 && < 0.12
, base64-bytestring >= 1.0.0.1 && < 1.3
, exceptions >= 0.10.0 && < 0.11
Expand Down
2 changes: 1 addition & 1 deletion servant-docs/servant-docs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ library
-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
-- Here can be exceptions if we really need features from the newer versions.
build-depends:
aeson >= 1.4.1.0 && < 1.6
aeson >= 1.4.1.0 && < 3
, aeson-pretty >= 0.8.5 && < 0.9
, base-compat >= 0.10.5 && < 0.12
, case-insensitive >= 1.2.0.11 && < 1.3
Expand Down
4 changes: 2 additions & 2 deletions servant-server/servant-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ executable greet
, text

build-depends:
aeson >= 1.4.1.0 && < 1.6
aeson >= 1.4.1.0 && < 3
, warp >= 3.2.25 && < 3.4

test-suite spec
Expand Down Expand Up @@ -157,7 +157,7 @@ test-suite spec

-- Additional dependencies
build-depends:
aeson >= 1.4.1.0 && < 1.6
aeson >= 1.4.1.0 && < 3
, directory >= 1.3.0.0 && < 1.4
, hspec >= 2.6.0 && < 2.9
, hspec-wai >= 0.10.1 && < 0.12
Expand Down
143 changes: 143 additions & 0 deletions servant-swagger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
1.1.9
-------

* Support `servant-0.18`

1.1.8
-------

* Support `servant-0.17`

1.1.7.1
-------

* Support `swagger2-2.4`

1.1.7
-----

* Support servant-0.15
- support for 'Stream' and 'StreamBody' combinators
- orphan 'ToSchema (SourceT m a)' instance
* Fix BodyTypes to work with generalized ReqBody'
[#88](https://github.com/haskell-servant/servant-swagger/pull/88)

1.1.6
-----

* Fixes:
* `validateEveryToJSON` now prints validation errors

* Notes:
* GHC-8.6 compatible release

1.1.5
-----

* Notes:
* `servant-0.13` compatible release
* Drops compatibility with previous `servant` versions.

1.1.4
-----

* Notes:
* `servant-0.12` compatible release

1.1.3.1
---

* Notes:
* GHC-8.2 compatible release

1.1.3
---

* Notes:
* `servant-0.11` compatible release

1.1.2.1
---

* Notes:
* `servant-0.10` compatible release

1.1.2
---

* Minor fixes:
* Support for aeson-1, insert-ordered-containers-0.2
* CaptureAll instance

1.1.1
---

* Minor fixes:
* Fix `unused-imports` and `unused-foralls` warnings;
* Fix tests to match `swagger2-2.1.1` (add `example` property for `UTCTime` schema).

1.1
---

* Breaking changes:
* Requires `swagger2 >= 2.1`
* Requires `servant >= 0.5`

* Notes:
* GHC-8.0 compatible release

1.0.3
---

* Fixes:
* Improve compile-time performance of `BodyTypes` even further (see [18e0d95](https://github.com/haskell-servant/servant-swagger/commit/18e0d95ef6fe9076dd9621cb515d8d1a189f71d3))!

1.0.2
---

* Minor changes:
* Add GHC 7.8 support (see [#26](https://github.com/haskell-servant/servant-swagger/pull/26)).

* Fixes:
* Improve compile-time performance of `BodyTypes` (see [#25](https://github.com/haskell-servant/servant-swagger/issues/25)).

1.0.1
---

* Fixes:
* Stop using `Data.Swagger.Internal`;
* Documentation fixes (links to examples).

1.0
---

* Major changes (see [#24](https://github.com/haskell-servant/servant-swagger/pull/24)):
* Switch to `swagger2-2.*`;
* Add automatic `ToJSON`/`ToSchema` validation tests;
* Add great documentation;
* Export some type-level functions for servant API.

* Minor changes:
* Rework Todo API example;
* Stop exporting `ToResponseHeader`, `AllAccept` and `AllToResponseHeader` (see [bd50db4](https://github.com/haskell-servant/servant-swagger/commit/bd50db48ca6a106e4366560ded70932d409de1e2));
* Change maintainer, update authors/copyrights (see [1a62681](https://github.com/haskell-servant/servant-swagger/commit/1a6268101dc826a92c42e832e402e251c0d32147));
* Include changelog and example files into `extra-source-files`.

0.1.2
---

* Fixes:
* Fix default spec for `ReqBody` param to be required (see [#22](https://github.com/haskell-servant/servant-swagger/issues/22));
* Set version bounds for `swagger2`.

0.1.1
---

* Fixes:
* Fix `subOperations` to filter endpoints also by method (see [#18](https://github.com/haskell-servant/servant-swagger/issues/18));
* Fix response schema in `ToSwagger` instance for `Header` (see [b59e557](https://github.com/haskell-servant/servant-swagger/commit/b59e557a05bc2669332c52b397879e7598747b82)).

0.1
---
* Major changes
* Use `swagger2` for data model (see [#9](https://github.com/dmjio/servant-swagger/pull/9)); this changes almost everything.
28 changes: 28 additions & 0 deletions servant-swagger/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright (c) 2015-2016, Servant contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of servant-swagger nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

46 changes: 46 additions & 0 deletions servant-swagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# servant-swagger

[![Hackage](https://img.shields.io/hackage/v/servant-swagger.svg)](http://hackage.haskell.org/package/servant-swagger)
[![Stackage LTS](http://stackage.org/package/servant-swagger/badge/lts)](http://stackage.org/lts/package/servant-swagger)
[![Stackage Nightly](http://stackage.org/package/servant-swagger/badge/nightly)](http://stackage.org/nightly/package/servant-swagger)

Swagger 2.0 conforming json for [servant](https://github.com/haskell-servant/servant) APIs.

![servant-swagger robot](http://s16.postimg.org/rndz1wbyt/servant.png)

### Motivation

Swagger is a project used to describe and document RESTful APIs.
Unlike Servant it is language-agnostic and thus is quite popular among developers
in different languages. It also exists for a longer time and has more tools to work with.

This package provides means to generate Swagger specification for a Servant API
and also to partially test whether API conforms with its specification.

Generated Swagger specification then can be used for many things such as
- displaying interactive documentation using [Swagger UI](http://swagger.io/swagger-ui/);
- generating clients and servers in many languages using [Swagger Codegen](http://swagger.io/swagger-codegen/);
- and [many others](http://swagger.io/open-source-integrations/).

### Usage

Please refer to [haddock documentation](http://hackage.haskell.org/package/servant/servant-swagger).

Some examples can be found in [`example/` directory](/example).

### Try it out

All generated swagger specifications can be interactively viewed on [Swagger Editor](http://editor.swagger.io/).

Ready-to-use specification can be served as JSON and interactive API documentation
can be displayed using [Swagger UI](https://github.com/swagger-api/swagger-ui).

Many Swagger tools, including server and client code generation for many languages, can be found on
[Swagger's Tools and Integrations page](http://swagger.io/open-source-integrations/).

### Contributing

We are happy to receive bug reports, fixes, documentation enhancements, and other improvements.

Please report bugs via the [github issue tracker](https://github.com/haskell-servant/servant/issues).

33 changes: 33 additions & 0 deletions servant-swagger/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wall #-}
module Main (main) where

#ifndef MIN_VERSION_cabal_doctest
#define MIN_VERSION_cabal_doctest(x,y,z) 0
#endif

#if MIN_VERSION_cabal_doctest(1,0,0)

import Distribution.Extra.Doctest ( defaultMainWithDoctests )
main :: IO ()
main = defaultMainWithDoctests "doctests"

#else

#ifdef MIN_VERSION_Cabal
-- If the macro is defined, we have new cabal-install,
-- but for some reason we don't have cabal-doctest in package-db
--
-- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
#warning You are configuring this package without cabal-doctest installed. \
The doctests test-suite will not work as a result. \
To fix this, install cabal-doctest before configuring.
#endif

import Distribution.Simple

main :: IO ()
main = defaultMain

#endif

0 comments on commit 9a39799

Please sign in to comment.