Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish v0.2.1 #6

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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