-
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.
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
json-fleece-openapi3/examples/test-cases/TestCases/Operations/TestCases/ParamRef.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,59 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module TestCases.Operations.TestCases.ParamRef | ||
( operation | ||
, route | ||
, HeaderParams(..) | ||
, headerParamsSchema | ||
, Responses(..) | ||
, responseSchemas | ||
) where | ||
|
||
import Beeline.HTTP.Client ((?+)) | ||
import qualified Beeline.HTTP.Client as H | ||
import Beeline.Routing ((/-)) | ||
import qualified Beeline.Routing as R | ||
import Prelude (($), Eq, Show, fmap) | ||
import qualified TestCases.Operations.TestCases.ParamRef.XSampleHeaderParam as XSampleHeaderParam | ||
|
||
operation :: | ||
H.Operation | ||
H.ContentTypeDecodingError | ||
H.NoPathParams | ||
H.NoQueryParams | ||
HeaderParams | ||
H.NoRequestBody | ||
Responses | ||
operation = | ||
H.defaultOperation | ||
{ H.requestRoute = route | ||
, H.requestHeaderSchema = headerParamsSchema | ||
, H.responseSchemas = responseSchemas | ||
} | ||
|
||
route :: R.Router r => r H.NoPathParams | ||
route = | ||
R.get $ | ||
R.make H.NoPathParams | ||
/- "test-cases" | ||
/- "param-ref" | ||
|
||
data HeaderParams = HeaderParams | ||
{ xSampleHeaderParam :: XSampleHeaderParam.XSampleHeaderParam | ||
} | ||
deriving (Eq, Show) | ||
|
||
headerParamsSchema :: H.ParameterCollectionSchema p => p HeaderParams HeaderParams | ||
headerParamsSchema = | ||
H.makeParams HeaderParams | ||
?+ H.required xSampleHeaderParam XSampleHeaderParam.paramDef | ||
|
||
data Responses | ||
= Response204 H.NoResponseBody | ||
deriving (Eq, Show) | ||
|
||
responseSchemas :: [(H.StatusRange, H.ResponseBodySchema H.ContentTypeDecodingError Responses)] | ||
responseSchemas = | ||
[ (H.Status 204, fmap Response204 (H.noResponseBody)) | ||
] |
17 changes: 17 additions & 0 deletions
17
...penapi3/examples/test-cases/TestCases/Operations/TestCases/ParamRef/XSampleHeaderParam.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,17 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module TestCases.Operations.TestCases.ParamRef.XSampleHeaderParam | ||
( XSampleHeaderParam(..) | ||
, paramDef | ||
) where | ||
|
||
import qualified Beeline.Routing as R | ||
import Prelude (Bool, Eq, Show) | ||
|
||
newtype XSampleHeaderParam = XSampleHeaderParam Bool | ||
deriving (Show, Eq) | ||
|
||
paramDef :: R.ParameterDefinition XSampleHeaderParam | ||
paramDef = | ||
R.coerceParam (R.booleanParam "X-Sample-Header-Param") |
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