git.iko.soy/deriving-openapi3
on master help sign in
4 files changed+13−78
since splitsnapshots
unifiedsplit
.github/workflows/build.yaml+2−6 deriving-openapi3.cabal+3−11 package.yaml−51 src/Deriving/OpenApi.hs+8−10
.github/workflows/build.yaml+2−6
@@ -17,7 +17,7 @@ jobs:
1717 - name: Check library version
1818 if: github.event_name == 'release'
1919 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
2121 echo "::error file=action.yaml::Library version does not match release version."
2222 exit 1
2323 fi
@@ -33,15 +33,11 @@ jobs:
3333 path: |
3434 ~/.stack
3535 .stack-work
36− key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
36+ key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}-${{ hashFiles('**.cabal') }}
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−
4541 - name: Build
4642 shell: bash
4743 run: |
deriving-openapi3.cabal+3−11
@@ -22,11 +22,6 @@ 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−
3025library
3126 exposed-modules:
3227 Deriving.OpenApi
@@ -48,16 +43,13 @@ library
4843 OverloadedStrings
4944 DerivingStrategies
5045 DerivingVia
46+ FlexibleContexts
5147 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
5248 build-depends:
5349 aeson
54− , base
55− , deriving-aeson
50+ , base >=4.12
51+ , deriving-aeson >=0.2.2
5652 , lens
5753 , openapi3
5854 , text
59− if flag(servant-description)
60− cpp-options: -DSERVANT_DESCRIPTION
61− build-depends:
62− servant
6355 default-language: Haskell2010
package.yamldeleted−51
@@ -1,51 +0,0 @@
1−name: deriving-openapi3
2−version: 0.1.0.0
3−synopsis: DerivingVia for OpenAPI 3
4−description: DerivingVia for OpenAPI 3
5−maintainer: Ilya Kostyuchenko <ilyakooo0@gmail.com>
6−category: JSON, Generics, OpenAPI
7−license: MIT
8−license-file: LICENSE
9−extra-source-files: Changelog.md
10−github: ilyakooo0/deriving-openapi3
11−ghc-options: -Weverything
12− -Wno-star-is-type
13− -Wno-unsafe
14− -Wno-prepositive-qualified-module
15− -Wno-safe
16− -Wno-missing-safe-haskell-mode
17− -Wno-missing-import-lists
18− -Wno-implicit-prelude
19−dependencies:
20− - base
21− - openapi3
22− - deriving-aeson
23− - aeson
24− - lens
25− - text
26−when:
27− - condition: flag(servant-description)
28− dependencies:
29− - servant
30− cpp-options: -DSERVANT_DESCRIPTION
31−library:
32− source-dirs: src
33−default-extensions:
34− - AllowAmbiguousTypes
35− - ScopedTypeVariables
36− - KindSignatures
37− - DataKinds
38− - TypeOperators
39− - FlexibleInstances
40− - TypeApplications
41− - UndecidableInstances
42− - TypeFamilies
43− - PolyKinds
44− - OverloadedStrings
45− - DerivingStrategies
46− - DerivingVia
47−flags:
48− servant-description:
49− description: Create instances for the 'Description' type from 'servant'
50− default: true
51− manual: false
src/Deriving/OpenApi.hs+8−10
@@ -42,20 +42,14 @@ 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
4547import Data.Typeable
4648import Deriving.Aeson
4749import GHC.Generics
4850import GHC.TypeLits
4951
50−-- $setup
51−-- >>> import qualified Data.Yaml
52−-- >>> import qualified Data.ByteString.Char8
53−
54−#ifdef SERVANT_DESCRIPTION
55−
56−import Servant.API
57−import Data.Text (Text)
58−import qualified Data.Text as T
52+data Description (desc :: Symbol) = Description
5953
6054instance (AesonOptions xs) => AesonOptions (Description f ': xs) where
6155 aesonOptions = aesonOptions @xs
@@ -66,7 +60,9 @@ instance KnownSymbol t => OpenApiOptionModifier (Description t) where
6660toTextLine :: forall s. KnownSymbol s => Text
6761toTextLine = "\n\n" <> T.pack (symbolVal (Proxy @s))
6862
69−#endif
63+-- $setup
64+-- >>> import qualified Data.Yaml
65+-- >>> import qualified Data.ByteString.Char8
7066
7167type CustomOpenApi = CustomJSON
7268
@@ -106,8 +102,10 @@ instance OpenApiOptionModifier UnwrapUnaryRecords where
106102
107103instance OpenApiOptionModifier OmitNothingFields
108104
105+#if MIN_VERSION_deriving_aeson(0,2,4)
109106instance OpenApiOptionModifier RejectUnknownFields where
110107 openApiSchemaModifier = schema . additionalProperties .~ Just (AdditionalPropertiesAllowed False)
108+#endif
111109
112110instance StringModifier f => OpenApiOptionModifier (FieldLabelModifier f) where
113111 openApiOptionsModifier o = o {fieldLabelModifier = getStringModifier @f}