git.iko.soy/deriving-openapi3
on 526a8fd help sign in
3 files changed+24−8
since splitsnapshots
unifiedsplit
.github/workflows/build.yaml+6−2 deriving-openapi3.cabal+11−3 src/Deriving/OpenApi.hs+7−3
.github/workflows/build.yaml+6−2
@@ -17,7 +17,7 @@ jobs:
1717 - name: Check library version
1818 if: github.event_name == 'release'
1919 run: |
20− if [ "$(awk -F":" '{if ($1 == "version") {gsub(/ /, "", $2); print $2}}' *.cabal)" != "${{ github.event.release.tag_name }}" ]; then
20+ if [ "$(yq eval ".version" package.yaml)" != "${{ github.event.release.tag_name }}" ]; then
2121 echo "::error file=action.yaml::Library version does not match release version."
2222 exit 1
2323 fi
@@ -33,11 +33,15 @@ jobs:
3333 path: |
3434 ~/.stack
3535 .stack-work
36− key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
36+ key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
3737 restore-keys: |
3838 ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
3939 ${{ runner.os }}-stack
4040
41+ - name: Upgrade stack
42+ shell: bash
43+ run: stack upgrade --git
44+
4145 - name: Build
4246 shell: bash
4347 run: |
deriving-openapi3.cabal+11−3
@@ -22,6 +22,11 @@ source-repository head
2222 type: git
2323 location: https://github.com/ilyakooo0/deriving-openapi3
2424
25+flag servant-description
26+ description: Create instances for the 'Description' type from 'servant'
27+ manual: False
28+ default: True
29+
2530library
2631 exposed-modules:
2732 Deriving.OpenApi
@@ -43,13 +48,16 @@ library
4348 OverloadedStrings
4449 DerivingStrategies
4550 DerivingVia
46− FlexibleContexts
4751 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
4852 build-depends:
4953 aeson
50− , base >=4.12
51− , deriving-aeson >=0.2.2
54+ , base
55+ , deriving-aeson
5256 , lens
5357 , openapi3
5458 , text
59+ if flag(servant-description)
60+ cpp-options: -DSERVANT_DESCRIPTION
61+ build-depends:
62+ servant
5563 default-language: Haskell2010
src/Deriving/OpenApi.hs+7−3
@@ -42,14 +42,16 @@ import Data.OpenApi
4242import Data.OpenApi.Internal.ParamSchema
4343import Data.OpenApi.Internal.Schema
4444import Data.Proxy
45−import Data.Text (Text)
46−import qualified Data.Text as T
4745import Data.Typeable
4846import Deriving.Aeson
4947import GHC.Generics
5048import GHC.TypeLits
5149
52−data Description (desc :: Symbol) = Description
50+#ifdef SERVANT_DESCRIPTION
51+
52+import Servant.API
53+import Data.Text (Text)
54+import qualified Data.Text as T
5355
5456instance (AesonOptions xs) => AesonOptions (Description f ': xs) where
5557 aesonOptions = aesonOptions @xs
@@ -60,6 +62,8 @@ instance KnownSymbol t => OpenApiOptionModifier (Description t) where
6062toTextLine :: forall s. KnownSymbol s => Text
6163toTextLine = "\n\n" <> T.pack (symbolVal (Proxy @s))
6264
65+#endif
66+
6367-- $setup
6468-- >>> import qualified Data.Yaml
6569-- >>> import qualified Data.ByteString.Char8