Skip to content

Commit

Permalink
Merge pull request #6 from bruderj15/main
Browse files Browse the repository at this point in the history
Publish v0.2.1
  • Loading branch information
bruderj15 authored Oct 29, 2024
2 parents 3d7ba7a + 908c341 commit d334a7d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PVP versioning](https://pvp.haskell.org/).

## v0.2.1 _(2024-10-25)_

### Changed
- Export `CollectionItem`
- Improved documentation

## v0.2.0 _(2024-10-29)_

### Added
- Support for Content-Type `application/collection+json`
- Classes `EmbeddingResource res` & `CollectingResource res` for resource-modification

### Changed

- *(breaking change)* Renamed class `HasResource` to `Resource`, removed associated type and Content-Type param

## v0.1.1 _(2024-10-25)_
Expand Down
2 changes: 1 addition & 1 deletion servant-hateoas.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: servant-hateoas
version: 0.2.0
version: 0.2.1
synopsis: HATEOAS extension for servant
description: Create Resource-Representations for your types and make your API HATEOAS-compliant.
Resource construction is generic where possible and manually adjustable where required.
Expand Down
11 changes: 6 additions & 5 deletions src/Servant/Hateoas/ContentType/Collection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module Servant.Hateoas.ContentType.Collection
( Collection
, CollectionResource(..)
, CollectionItem(..)
)
where

Expand All @@ -28,15 +29,15 @@ data Collection (t :: Type)

-- | Resource wrapper for 'Collection'.
data CollectionResource a = CollectionResource
{ href :: Maybe Link
, items :: [CollectionItem a]
, links :: [(String, Link)]
{ href :: Maybe Link -- ^ Link to the collection
, items :: [CollectionItem a] -- ^ All items in the collection
, links :: [(String, Link)] -- ^ Pairs @(rel, link)@ for relations
} deriving (Show, Generic)

-- | A single item inside a 'CollectionResource'.
data CollectionItem a = CollectionItem
{ item :: a
, itemLinks :: [(String, Link)]
{ item :: a -- ^ Wrapped item
, itemLinks :: [(String, Link)] -- ^ Links for the wrapped item
} deriving (Show, Generic)

instance Resource CollectionResource where
Expand Down
8 changes: 4 additions & 4 deletions src/Servant/Hateoas/ContentType/HAL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import GHC.TypeLits
import GHC.Generics
import GHC.Records

-- | Data-Kind representing Content-Types with Hypertext Application Language (HAL).
-- | Data-Kind representing Content-Types of Hypertext Application Language (HAL).
--
-- Type parameter @t@ is the mime type suffix in @application/hal+t@.
data HAL (t :: Type)

-- | Resource wrapper for HAL.
data HALResource a = HALResource
{ resource :: a
, links :: [(String, Link)]
, embedded :: [(String, SomeToJSON HALResource)]
{ resource :: a -- ^ Wrapped resource
, links :: [(String, Link)] -- ^ Pairs @(rel, link)@ for relations
, embedded :: [(String, SomeToJSON HALResource)] -- ^ Pairs @(rel, resource)@ for embedded resources
} deriving (Generic)

instance Resource HALResource where
Expand Down

0 comments on commit d334a7d

Please sign in to comment.