Skip to content

Commit

Permalink
Address doctest v0.20.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ysangkok committed Oct 19, 2022
1 parent f1f4e7e commit 6b66f2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions openapi3.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ test-suite doctests
hs-source-dirs: test
main-is: doctests.hs
type: exitcode-stdio-1.0
build-depends: base, openapi3

executable example
hs-source-dirs: examples
Expand Down
5 changes: 4 additions & 1 deletion src/Data/OpenApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ import Data.OpenApi.Internal
-- >>> import Data.Proxy
-- >>> import GHC.Generics
-- >>> import qualified Data.ByteString.Lazy.Char8 as BSL
-- >>> import Data.OpenApi.Internal
-- >>> import Data.OpenApi.Internal.Schema
-- >>> import Data.OpenApi.Internal.Utils
-- >>> import Data.OpenApi.Lens
-- >>> :set -XDeriveGeneric
-- >>> :set -XOverloadedStrings
-- >>> :set -XOverloadedLists
Expand Down Expand Up @@ -213,7 +216,7 @@ import Data.OpenApi.Internal
-- BSL.putStrLn $ encodePretty $ (mempty :: OpenApi)
-- & components . schemas .~ [ ("User", mempty & type_ ?~ OpenApiString) ]
-- & paths .~
-- [ ("/user", mempty & get ?~ (mempty
-- [ ("/user", mempty & Data.OpenApi.Lens.get ?~ (mempty
-- & at 200 ?~ ("OK" & _Inline.content.at "application/json" ?~ (mempty & schema ?~ Ref (Reference "User")))
-- & at 404 ?~ "User info not found")) ]
-- :}
Expand Down
7 changes: 7 additions & 0 deletions src/Data/OpenApi/Internal/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ unname (NamedSchema _ schema) = unnamed schema
rename :: Maybe T.Text -> NamedSchema -> NamedSchema
rename name (NamedSchema _ schema) = NamedSchema name schema

-- $setup
-- >>> import Data.Aeson.Types (toJSONKeyText)
-- >>> import qualified Data.ByteString.Lazy.Char8 as BSL
-- >>> import Data.OpenApi.Internal
-- >>> import Data.OpenApi.Internal.Utils (encodePretty)
-- >>> import Data.OpenApi.Lens (name, schema)

-- | Convert a type into @'Schema'@.
--
-- An example type and instance:
Expand Down
3 changes: 3 additions & 0 deletions src/Data/OpenApi/Internal/Schema/Validation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import Data.OpenApi.Internal.Schema
import Data.OpenApi.Internal.Utils
import Data.OpenApi.Lens

-- $setup
-- >>> import Data.OpenApi.Internal.Schema.Validation

-- | Validate @'ToJSON'@ instance matches @'ToSchema'@ for a given value.
-- This can be used with QuickCheck to ensure those instances are coherent:
--
Expand Down

0 comments on commit 6b66f2d

Please sign in to comment.