git.iko.soy/deriving-openapi3
on master help sign in
.github/workflows/build.yaml+2−2
since splitsnapshots
unifiedsplit
@@ -17,7 +17,7 @@ jobs:
17 - name: Check library version
17 - name: Check library version
18 if: github.event_name == 'release'
18 if: github.event_name == 'release'
19 run: |
19 run: |
20− if [ "$(yq eval ".version" package.yaml)" != "${{ github.event.release.tag_name }}" ]; then
20+ if [ "$(awk -F":" '{if ($1 == "version") {gsub(/ /, "", $2); print $2}}' *.cabal)" != "${{ github.event.release.tag_name }}" ]; then
21 echo "::error file=action.yaml::Library version does not match release version."
21 echo "::error file=action.yaml::Library version does not match release version."
22 exit 1
22 exit 1
23 fi
23 fi
@@ -33,7 +33,7 @@ jobs:
33 path: |
33 path: |
34 ~/.stack
34 ~/.stack
35 .stack-work
35 .stack-work
36− key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
36+ key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
37 restore-keys: |
37 restore-keys: |
38 ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
38 ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
39 ${{ runner.os }}-stack
39 ${{ runner.os }}-stack
deriving-openapi3.cabal+3−11
@@ -22,11 +22,6 @@ source-repository head
22 type: git
22 type: git
23 location: https://github.com/ilyakooo0/deriving-openapi3
23 location: https://github.com/ilyakooo0/deriving-openapi3
24
24
25−flag servant-description
26− description: Create instances for the 'Description' type from 'servant'
27− manual: False
28− default: True
29−
30library
25library
31 exposed-modules:
26 exposed-modules:
32 Deriving.OpenApi
27 Deriving.OpenApi
@@ -48,16 +43,13 @@ library
48 OverloadedStrings
43 OverloadedStrings
49 DerivingStrategies
44 DerivingStrategies
50 DerivingVia
45 DerivingVia
46+ FlexibleContexts
51 ghc-options: -Weverything -Wno-star-is-type -Wno-unsafe -Wno-prepositive-qualified-module -Wno-safe -Wno-missing-safe-haskell-mode -Wno-missing-import-lists -Wno-implicit-prelude
47 ghc-options: -Weverything -Wno-star-is-type -Wno-unsafe -Wno-prepositive-qualified-module -Wno-safe -Wno-missing-safe-haskell-mode -Wno-missing-import-lists -Wno-implicit-prelude
52 build-depends:
48 build-depends:
53 aeson
49 aeson
54− , base
50+ , base >=4.12
55− , deriving-aeson
51+ , deriving-aeson >=0.2.2
56 , lens
52 , lens
57 , openapi3
53 , openapi3
58 , text
54 , text
59− if flag(servant-description)
60− cpp-options: -DSERVANT_DESCRIPTION
61− build-depends:
62− servant
63 default-language: Haskell2010
55 default-language: Haskell2010
src/Deriving/OpenApi.hs+3−7
@@ -42,16 +42,14 @@ import Data.OpenApi
42import Data.OpenApi.Internal.ParamSchema
42import Data.OpenApi.Internal.ParamSchema
43import Data.OpenApi.Internal.Schema
43import Data.OpenApi.Internal.Schema
44import Data.Proxy
44import Data.Proxy
45+import Data.Text (Text)
46+import qualified Data.Text as T
45import Data.Typeable
47import Data.Typeable
46import Deriving.Aeson
48import Deriving.Aeson
47import GHC.Generics
49import GHC.Generics
48import GHC.TypeLits
50import GHC.TypeLits
49
51
50−#ifdef SERVANT_DESCRIPTION
52+data Description (desc :: Symbol) = Description
51−
52−import Servant.API
53−import Data.Text (Text)
54−import qualified Data.Text as T
55
53
56instance (AesonOptions xs) => AesonOptions (Description f ': xs) where
54instance (AesonOptions xs) => AesonOptions (Description f ': xs) where
57 aesonOptions = aesonOptions @xs
55 aesonOptions = aesonOptions @xs
@@ -62,8 +60,6 @@ instance KnownSymbol t => OpenApiOptionModifier (Description t) where
62toTextLine :: forall s. KnownSymbol s => Text
60toTextLine :: forall s. KnownSymbol s => Text
63toTextLine = "\n\n" <> T.pack (symbolVal (Proxy @s))
61toTextLine = "\n\n" <> T.pack (symbolVal (Proxy @s))
64
62
65−#endif
66−
67-- $setup
63-- $setup
68-- >>> import qualified Data.Yaml
64-- >>> import qualified Data.Yaml
69-- >>> import qualified Data.ByteString.Char8
65-- >>> import qualified Data.ByteString.Char8