Introduce new 'Prefer' header, params=single-object (#739)

This commit is contained in:
dsimunic
2016-11-20 14:14:39 -08:00
committed by Joe Nelson
parent 4df853eff9
commit ae40641963
8 changed files with 46 additions and 8 deletions
+14
View File
@@ -609,6 +609,20 @@ spec = do
post "/rpc/callcounter" [json| {} |] `shouldRespondWith`
[json|2|]
context "expects a single json object" $ do
it "does not expand posted json into parameters" $
request methodPost "/rpc/singlejsonparam"
[("Prefer","params=single-object")] [json| { "p1": 1, "p2": "text", "p3" : {"obj":"text"} } |] `shouldRespondWith`
[json| { "p1": 1, "p2": "text", "p3" : {"obj":"text"} } |]
it "accepts parameters from an html form" $
request methodPost "/rpc/singlejsonparam"
[("Prefer","params=single-object"),("Content-Type", "application/x-www-form-urlencoded")]
("integer=7&double=2.71828&varchar=forms+are+fun&" <>
"boolean=false&date=1900-01-01&money=$3.99&enum=foo") `shouldRespondWith`
[json| { "integer": "7", "double": "2.71828", "varchar" : "forms are fun"
, "boolean":"false", "date":"1900-01-01", "money":"$3.99", "enum":"foo" } |]
describe "weird requests" $ do
it "can query as normal" $ do
get "/Escap3e;" `shouldRespondWith`
+1 -1
View File
@@ -33,7 +33,7 @@ spec = do
r <- simpleBody <$> get "/"
let ref = r ^? key "paths" . key "/rpc/varied_arguments"
. key "post" . key "parameters"
. nth 0 . key "schema"
. nth 1 . key "schema"
. key "$ref" . _String
args = r ^? key "definitions" . key "(rpc) varied_arguments"
+10
View File
@@ -322,6 +322,16 @@ CREATE FUNCTION callcounter() RETURNS bigint
SELECT nextval('test.callcounter_count');
$_$;
--
-- Name: singlejsonparam(json); Type: FUNCTION; Schema: test; Owner: -
--
CREATE FUNCTION singlejsonparam(single_param json) RETURNS json
LANGUAGE sql
AS $_$
SELECT single_param;
$_$;
--
-- Name: test_empty_rowset(); Type: FUNCTION; Schema: test; Owner: -
--