json-api 0.1.2.0 → 0.1.3.0
raw patch · 10 files changed
+153/−143 lines, 10 filesdep ~aesondep ~aeson-prettydep ~bytestring
Dependency ranges changed: aeson, aeson-pretty, bytestring, containers, data-default, hspec, lens, lens-aeson, text, unordered-containers, url
Files
- example/example.cabal +9/−9
- json-api.cabal +83/−106
- src/Network/JSONApi/Document.hs +3/−2
- src/Network/JSONApi/Identifier.hs +0/−1
- src/Network/JSONApi/Meta.hs +3/−1
- src/Network/JSONApi/Resource.hs +3/−2
- stack.yaml +45/−16
- test/Network/JSONApi/DocumentSpec.hs +3/−4
- test/Network/JSONApi/ResourceSpec.hs +0/−1
- test/TestHelpers.hs +4/−1
example/example.cabal view
@@ -1,5 +1,5 @@ name: example-version: 0.1.0.3+version: 0.1.0.4 synopsis: Initial project template from stack description: Please see README.md homepage: https://github.com/toddmohney/example#readme@@ -28,15 +28,15 @@ Users.Actions.Show build-depends: base >= 4.7 && < 5- , aeson >= 0.11.2.0 && < 0.11.3.0- , containers >= 0.5.7.1 && < 0.5.8.0- , data-default >= 0.5.3 && < 5.6.0+ , aeson+ , containers+ , data-default , json-api- , servant-server >= 0.7.1 && < 0.8.0- , text >= 1.2.2.1 && < 1.2.3.0- , url >= 2.1.3 && < 2.2.0- , unordered-containers >= 0.2.7.1 && < 0.2.8.0- , wai >= 3.2.1.1 && < 3.2.2.0+ , servant-server+ , text+ , url+ , unordered-containers+ , wai , warp default-language: Haskell2010
json-api.cabal view
@@ -1,120 +1,97 @@-name: json-api-version: 0.1.2.0-homepage: https://github.com/toddmohney/json-api-bug-reports: https://github.com/toddmohney/json-api/issues-license: MIT-license-file: LICENSE-author: Todd Mohney-maintainer: Todd Mohney <toddmohney@gmail.com>-copyright: 2016 Todd Mohney-category: Network-build-type: Simple-cabal-version: >=1.10-stability: experimental-tested-with: GHC == 7.10.3-synopsis: Utilities for generating JSON-API payloads-description:- Provides utilities for deriving JSON payloads conformant to the json-api- specification+cabal-version: 1.12 +-- This file has been generated from package.yaml by hpack version 0.31.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 85cd43545d985dbf21e9ce90c112c8efc0c8553f194f84544f71d465a6a3a101++name: json-api+version: 0.1.3.0+synopsis: Utilities for generating JSON-API payloads+description: Provides utilities for deriving JSON payloads conformant to the json-api specification+category: Network+stability: experimental+homepage: https://github.com/toddmohney/json-api.git#readme+bug-reports: https://github.com/toddmohney/json-api.git/issues+author: Todd Mohney+maintainer: Todd Mohney <toddmohney@gmail.com>+copyright: 2016 Todd Mohney+license: MIT+license-file: LICENSE+tested-with: ghc ==7.10.3+build-type: Simple extra-source-files:- README.md- LICENSE- circle.yml- stack.yaml- example/LICENSE- example/README.md- example/example.cabal- example/*.hs- example/stack.yaml+ README.md+ LICENSE+ circle.yml+ stack.yaml+ example/LICENSE+ example/README.md+ example/example.cabal+ example/Setup.hs+ example/stack.yaml source-repository head type: git location: https://github.com/toddmohney/json-api.git library- build-depends: aeson >= 0.11.2.0 && < 0.11.3.0- , base >= 4.7 && < 5.0- , containers >= 0.5.7.1 && < 0.5.8.0- , data-default >= 0.5.3 && < 5.6.0- , lens >= 4.13 && < 5.0- , lens-aeson >= 1.0.0.5 && < 1.0.1.0- , text >= 1.2.2.1 && < 1.2.3.0- , unordered-containers >= 0.2.7.1 && < 0.2.8.0- , url >= 2.1.3 && < 2.2.0-- default-language: Haskell2010-- default-extensions:- DeriveGeneric- GeneralizedNewtypeDeriving- OverloadedStrings- RecordWildCards- TemplateHaskell- exposed-modules:- Network.JSONApi- Network.JSONApi.Error- Network.JSONApi.Document- Network.JSONApi.Identifier- Network.JSONApi.Meta- Network.JSONApi.Link- Network.JSONApi.Resource- Network.JSONApi.Pagination-+ Network.JSONApi+ Network.JSONApi.Error+ Network.JSONApi.Document+ Network.JSONApi.Identifier+ Network.JSONApi.Meta+ Network.JSONApi.Link+ Network.JSONApi.Resource+ Network.JSONApi.Pagination other-modules:-- ghc-options:- -Wall- -fwarn-unused-matches- -fwarn-unused-binds- -fwarn-unused-imports-- hs-source-dirs: src+ Paths_json_api+ hs-source-dirs:+ src+ default-extensions: DeriveGeneric GeneralizedNewtypeDeriving OverloadedStrings RecordWildCards TemplateHaskell+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fhide-source-paths -fno-warn-warnings-deprecations -freverse-errors -fwarn-unused-binds -fwarn-unused-imports -fwarn-unused-matches -fwarn-unused-imports+ build-depends:+ aeson+ , base >=4.7 && <5.0+ , containers+ , data-default+ , lens+ , lens-aeson+ , text+ , unordered-containers+ , url+ default-language: Haskell2010 test-suite json-api-test- build-depends: aeson >= 0.11.2.0 && < 0.11.3.0- , aeson-pretty >= 0.7.2 && < 0.8.0- , base >= 4.7 && < 5.0- , bytestring >= 0.10.8.1 && < 0.10.9.0- , containers >= 0.5.7.1 && < 0.5.8.0- , data-default >= 0.5.3 && < 5.6.0- , hspec >= 2.2.3 && < 2.3.0- , json-api- , lens >= 4.13 && < 5.0- , lens-aeson >= 1.0.0.5 && < 1.0.1.0- , text >= 1.2.2.1 && < 1.2.3.0- , unordered-containers >= 0.2.7.1 && < 0.2.8.0- , url >= 2.1.3 && < 2.2.0-- default-language: Haskell2010-- default-extensions:- DeriveGeneric- GeneralizedNewtypeDeriving- OverloadedStrings- RecordWildCards-- ghc-options:- -Wall- -fwarn-unused-matches- -fwarn-unused-binds-- hs-source-dirs: test-+ type: exitcode-stdio-1.0 main-is: Spec.hs- other-modules:- Network.JSONApi.ErrorSpec- Network.JSONApi.DocumentSpec- Network.JSONApi.IdentifierSpec- Network.JSONApi.MetaSpec- Network.JSONApi.PaginationSpec- Network.JSONApi.ResourceSpec- TestHelpers-- type: exitcode-stdio-1.0--source-repository head- type: git- location: https://github.com/toddmohney/json-api+ Network.JSONApi.DocumentSpec+ Network.JSONApi.ErrorSpec+ Network.JSONApi.IdentifierSpec+ Network.JSONApi.MetaSpec+ Network.JSONApi.PaginationSpec+ Network.JSONApi.ResourceSpec+ TestHelpers+ Paths_json_api+ hs-source-dirs:+ test+ default-extensions: DeriveGeneric GeneralizedNewtypeDeriving OverloadedStrings RecordWildCards+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -fhide-source-paths -fno-warn-warnings-deprecations -freverse-errors -fwarn-unused-binds -fwarn-unused-imports -fwarn-unused-matches+ build-depends:+ aeson+ , aeson-pretty+ , base >=4.7 && <5.0+ , bytestring+ , containers+ , data-default+ , hspec+ , json-api+ , lens+ , lens-aeson+ , text+ , unordered-containers+ , url+ default-language: Haskell2010
src/Network/JSONApi/Document.hs view
@@ -25,7 +25,6 @@ , (.:?) ) import qualified Data.Aeson as AE-import Data.Monoid import qualified GHC.Generics as G import qualified Network.JSONApi.Error as E import Network.JSONApi.Link as L@@ -83,9 +82,11 @@ data Included = Included [Value] deriving (Show) +instance Semigroup Included where+ (<>) (Included as) (Included bs) = Included (as <> bs)+ instance Monoid Included where mempty = Included []- mappend (Included as) (Included bs) = Included (as <> bs) {- | Constructor function for the Document data type.
src/Network/JSONApi/Identifier.hs view
@@ -14,7 +14,6 @@ import Control.Lens.TH import Data.Aeson (ToJSON, FromJSON, (.=), (.:), (.:?)) import qualified Data.Aeson as AE-import qualified Data.Aeson.Types as AE import Data.Text (Text) import Network.JSONApi.Meta (Meta) import Prelude hiding (id)
src/Network/JSONApi/Meta.hs view
@@ -41,8 +41,10 @@ instance ToJSON Meta instance FromJSON Meta +instance Semigroup Meta where+ (<>) (Meta a) (Meta b) = Meta $ HM.union a b+ instance Monoid Meta where- mappend (Meta a) (Meta b) = Meta $ HM.union a b mempty = Meta $ HM.empty {- |
src/Network/JSONApi/Resource.hs view
@@ -15,7 +15,6 @@ import Control.Lens.TH import Data.Aeson (ToJSON, FromJSON, (.=), (.:), (.:?)) import qualified Data.Aeson as AE-import qualified Data.Aeson.Types as AE import Data.Map (Map) import qualified Data.Map as Map import Data.Monoid@@ -112,9 +111,11 @@ instance ToJSON Relationships instance FromJSON Relationships +instance Semigroup Relationships where+ (<>) (Relationships a) (Relationships b) = Relationships (a <> b)+ instance Monoid Relationships where mempty = Relationships Map.empty- mappend (Relationships a) (Relationships b) = Relationships (a <> b) mkRelationships :: Relationship -> Relationships mkRelationships rel =
stack.yaml view
@@ -1,36 +1,65 @@-# This file was automatically generated by stack init-# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/+# This file was automatically generated by 'stack init'+#+# Some commonly used options have been documented as comments in this file.+# For advanced use and comprehensive documentation of the format, please see:+# https://docs.haskellstack.org/en/stable/yaml_configuration/ -# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)-# resolver: lts-6.4-resolver: nightly-2016-07-03+# Resolver to choose a 'specific' stackage snapshot or a compiler version.+# A snapshot resolver dictates the compiler version and the set of packages+# to be used for project dependencies. For example:+#+# resolver: lts-3.5+# resolver: nightly-2015-09-21+# resolver: ghc-7.10.2+#+# The location of a snapshot can be provided as a file or url. Stack assumes+# a snapshot provided as a file might change, whereas a url resource does not.+#+# resolver: ./custom-snapshot.yaml+# resolver: https://example.com/snapshots/2018-01-01.yaml+resolver: lts-13.27 -# Local packages, usually specified by relative directory name+# User packages to be built.+# Various formats can be used as shown in the example below.+#+# packages:+# - some-directory+# - https://example.com/foo/bar/baz-0.0.2.tar.gz+# - location:+# git: https://github.com/commercialhaskell/stack.git+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# subdirs:+# - auto-update+# - wai packages:- - '.'-# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)-extra-deps: []+- example+- .+# Dependency packages to be pulled from upstream that are not in the resolver+# using the same syntax as the packages field.+# (e.g., acme-missiles-0.3)+# extra-deps: [] # Override default flag values for local packages and extra-deps-flags: {}+# flags: {} # Extra package databases containing global packages-extra-package-dbs: []+# extra-package-dbs: [] # Control whether we use the GHC we find on the path # system-ghc: true-+# # Require a specific version of stack, using version ranges # require-stack-version: -any # Default-# require-stack-version: >= 1.0.0-+require-stack-version: ">=2.1"+# # Override the architecture used by stack, especially useful on Windows # arch: i386 # arch: x86_64-+# # Extra directories used by stack for building # extra-include-dirs: [/path/to/dir] # extra-lib-dirs: [/path/to/dir]-+# # Allow a newer minor version of GHC than the snapshot specifies # compiler-check: newer-minor
test/Network/JSONApi/DocumentSpec.hs view
@@ -5,10 +5,9 @@ import qualified Data.Aeson as AE import qualified Data.Aeson.Lens as Lens import Data.ByteString.Lazy.Char8 (ByteString)-{- import qualified Data.ByteString.Lazy.Char8 as BS -}+import qualified Data.ByteString.Lazy.Char8 as BS import Data.Either (isRight) import Data.Maybe-import Data.Monoid import Network.JSONApi import TestHelpers import Test.Hspec@@ -24,8 +23,8 @@ let jsonApiObj = mkDocument [testObject] Nothing Nothing let encodedJson = encodeDocumentObject jsonApiObj let decodedJson = decodeDocumentObject encodedJson- {- putStrLn (BS.unpack encodedJson) -}- {- putStrLn (show decodedJson) -}+ putStrLn (BS.unpack encodedJson)+ putStrLn (show decodedJson) isRight decodedJson `shouldBe` True it "JSON encodes/decodes a list of resources" $ do
test/Network/JSONApi/ResourceSpec.hs view
@@ -3,7 +3,6 @@ import qualified Data.Aeson as AE import qualified Data.ByteString.Lazy.Char8 as BS import Data.Maybe (isJust, fromJust)-import Data.Monoid import Data.Text (Text, pack) import GHC.Generics (Generic) import Network.JSONApi
test/TestHelpers.hs view
@@ -13,7 +13,10 @@ prettyEncode = AE.encodePretty' prettyConfig prettyConfig :: AE.Config-prettyConfig = AE.Config { AE.confIndent = 2, AE.confCompare = mempty }+prettyConfig = AE.defConfig+ { AE.confIndent = AE.Spaces 2+ , AE.confCompare = mempty+ } class HasIdentifiers a where uniqueId :: a -> Int