-
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.
Clean up oneOf code gen and support inline nullability
- Loading branch information
1 parent
1d79557
commit 5761301
Showing
12 changed files
with
256 additions
and
65 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
.../examples/test-cases/TestCases/Operations/TestCases/InlineNullableIntegerArrayResponse.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,46 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module TestCases.Operations.TestCases.InlineNullableIntegerArrayResponse | ||
( operation | ||
, route | ||
, Responses(..) | ||
, responseSchemas | ||
) where | ||
|
||
import qualified Beeline.HTTP.Client as H | ||
import Beeline.Routing ((/-)) | ||
import qualified Beeline.Routing as R | ||
import qualified Fleece.Aeson.Beeline as FA | ||
import qualified Fleece.Core as FC | ||
import Prelude (($), Either, Eq, Integer, Show, fmap) | ||
|
||
operation :: | ||
H.Operation | ||
H.ContentTypeDecodingError | ||
H.NoPathParams | ||
H.NoQueryParams | ||
H.NoHeaderParams | ||
H.NoRequestBody | ||
Responses | ||
operation = | ||
H.defaultOperation | ||
{ H.requestRoute = route | ||
, H.responseSchemas = responseSchemas | ||
} | ||
|
||
route :: R.Router r => r H.NoPathParams | ||
route = | ||
R.get $ | ||
R.make H.NoPathParams | ||
/- "test-cases" | ||
/- "inline-nullable-integer-array-response" | ||
|
||
data Responses | ||
= Response200 (Either FC.Null [Either FC.Null Integer]) | ||
deriving (Eq, Show) | ||
|
||
responseSchemas :: [(H.StatusRange, H.ResponseBodySchema H.ContentTypeDecodingError Responses)] | ||
responseSchemas = | ||
[ (H.Status 200, fmap Response200 (H.responseBody FA.JSON (FC.nullable (FC.list (FC.nullable FC.integer))))) | ||
] |
46 changes: 46 additions & 0 deletions
46
...napi3/examples/test-cases/TestCases/Operations/TestCases/InlineNullableIntegerResponse.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,46 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module TestCases.Operations.TestCases.InlineNullableIntegerResponse | ||
( operation | ||
, route | ||
, Responses(..) | ||
, responseSchemas | ||
) where | ||
|
||
import qualified Beeline.HTTP.Client as H | ||
import Beeline.Routing ((/-)) | ||
import qualified Beeline.Routing as R | ||
import qualified Fleece.Aeson.Beeline as FA | ||
import qualified Fleece.Core as FC | ||
import Prelude (($), Either, Eq, Integer, Show, fmap) | ||
|
||
operation :: | ||
H.Operation | ||
H.ContentTypeDecodingError | ||
H.NoPathParams | ||
H.NoQueryParams | ||
H.NoHeaderParams | ||
H.NoRequestBody | ||
Responses | ||
operation = | ||
H.defaultOperation | ||
{ H.requestRoute = route | ||
, H.responseSchemas = responseSchemas | ||
} | ||
|
||
route :: R.Router r => r H.NoPathParams | ||
route = | ||
R.get $ | ||
R.make H.NoPathParams | ||
/- "test-cases" | ||
/- "inline-nullable-integer-response" | ||
|
||
data Responses | ||
= Response200 (Either FC.Null Integer) | ||
deriving (Eq, Show) | ||
|
||
responseSchemas :: [(H.StatusRange, H.ResponseBodySchema H.ContentTypeDecodingError Responses)] | ||
responseSchemas = | ||
[ (H.Status 200, fmap Response200 (H.responseBody FA.JSON (FC.nullable FC.integer))) | ||
] |
35 changes: 35 additions & 0 deletions
35
json-fleece-openapi3/examples/test-cases/TestCases/Types/OneOfWithNullable.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,35 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module TestCases.Types.OneOfWithNullable | ||
( OneOfWithNullable(..) | ||
, oneOfWithNullableSchema | ||
) where | ||
|
||
import qualified Data.Text as T | ||
import Fleece.Core ((#|)) | ||
import qualified Fleece.Core as FC | ||
import Prelude (($), Either, Eq, Integer, Show) | ||
import qualified Shrubbery as Shrubbery | ||
import qualified TestCases.Types.AStringType as AStringType | ||
|
||
newtype OneOfWithNullable = OneOfWithNullable (Shrubbery.Union | ||
'[ Integer | ||
, Either FC.Null T.Text | ||
, Either FC.Null [Either FC.Null T.Text] | ||
, [AStringType.AStringType] | ||
, Either FC.Null [AStringType.AStringType] | ||
, [Either FC.Null [AStringType.AStringType]] | ||
]) | ||
deriving (Show, Eq) | ||
|
||
oneOfWithNullableSchema :: FC.Fleece schema => schema OneOfWithNullable | ||
oneOfWithNullableSchema = | ||
FC.coerceSchema $ | ||
FC.unionNamed (FC.qualifiedName "TestCases.Types.OneOfWithNullable" "OneOfWithNullable") $ | ||
FC.unionMember FC.integer | ||
#| FC.unionMember (FC.nullable FC.text) | ||
#| FC.unionMember (FC.nullable (FC.list (FC.nullable FC.text))) | ||
#| FC.unionMember (FC.list AStringType.aStringTypeSchema) | ||
#| FC.unionMember (FC.nullable (FC.list AStringType.aStringTypeSchema)) | ||
#| FC.unionMember (FC.list (FC.nullable (FC.list AStringType.aStringTypeSchema))) |
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
Oops, something went wrong.