-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
type: object
to be present on unions
- Loading branch information
1 parent
88ceb73
commit 18a5356
Showing
5 changed files
with
75 additions
and
25 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
json-fleece-openapi3/examples/test-cases/TestCases/Types/OneOfWithDiscriminatorTypeObject.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE ExplicitNamespaces #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
module TestCases.Types.OneOfWithDiscriminatorTypeObject | ||
( OneOfWithDiscriminatorTypeObject(..) | ||
, oneOfWithDiscriminatorTypeObjectSchema | ||
) where | ||
|
||
import Fleece.Core ((#@)) | ||
import qualified Fleece.Core as FC | ||
import Prelude (($), Eq, Show) | ||
import Shrubbery (type (@=)) | ||
import qualified Shrubbery as Shrubbery | ||
import qualified TestCases.Types.Bar as Bar | ||
import qualified TestCases.Types.Baz as Baz | ||
import qualified TestCases.Types.Foo as Foo | ||
|
||
newtype OneOfWithDiscriminatorTypeObject = OneOfWithDiscriminatorTypeObject (Shrubbery.TaggedUnion | ||
'[ "bar" @= Bar.Bar | ||
, "baz" @= Baz.Baz | ||
, "foo" @= Foo.Foo | ||
]) | ||
deriving (Show, Eq) | ||
|
||
oneOfWithDiscriminatorTypeObjectSchema :: FC.Fleece schema => schema OneOfWithDiscriminatorTypeObject | ||
oneOfWithDiscriminatorTypeObjectSchema = | ||
FC.coerceSchema $ | ||
FC.taggedUnionNamed (FC.qualifiedName "TestCases.Types.OneOfWithDiscriminatorTypeObject" "OneOfWithDiscriminatorTypeObject") "type" $ | ||
FC.taggedUnionMember @"bar" Bar.barSchema | ||
#@ FC.taggedUnionMember @"baz" Baz.bazSchema | ||
#@ FC.taggedUnionMember @"foo" Foo.fooSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters