on develop help sign in
Moving oauth_token into an Authorization header
commitdf4f01e87facfe61511988d8bf4d3bcae247ea4f authorBrendan Hay <brendan.g.hay@gmail.com> dateSun 11 Oct 2015, 11:50 (11 years ago) parent8ac8825
4 files changed+20−16
gen/src/Gen/AST/Flatten.hs+5−5 gen/src/Gen/AST/Solve.hs+9−8 gen/src/Gen/Syntax.hs+5−3 gen/src/Gen/Types/Schema.hs+1
gen/src/Gen/AST/Flatten.hs+5−5
@@ -110,11 +110,11 @@ schema g ml (Fix f) = go (maybe g (reference g) ml) f >>= uncurry insert
110110 g ml p
111111
112112globalParam :: Local -> Param (Fix Schema) -> AST (Param Global)
113−globalParam l p = ($ p) $ case l of
114− "alt" -> overrideParam l (Alt alt)
115− "key" -> overrideParam l Key
116− "oauth_token" -> overrideParam l OAuthToken
117− _ -> localParam "" l
113+globalParam l p = case l of
114+ "alt" -> overrideParam l (Alt alt) p
115+ "key" -> overrideParam l Key p
116+ "oauth_token" -> overrideParam l OAuthToken (p & pLocation .~ Header)
117+ _ -> localParam "" l p
118118 where
119119 alt = alternate $ fromMaybe "JSON" (p ^. iDefault)
120120
gen/src/Gen/AST/Solve.hs+9−8
@@ -128,15 +128,16 @@ getDerive g = loc "getDerive" g $ memo derived g go
128128 SObj _ (Obj _ ps) -> foldM props base (Map.elems ps)
129129
130130 literal = \case
131− Text -> base <> [DRead, DOrd, DIsString]
132− Bool -> enum
133− Time -> DRead : base
134− Date -> DRead : base
135− Body -> []
136− Alt _ -> DRead : base
137− Key -> DRead : base
131+ Text -> base <> [DRead, DOrd, DIsString]
132+ Bool -> enum
133+ Time -> DRead : base
134+ Date -> DRead : base
135+ Body -> []
136+ Alt _ -> DRead : base
137+ Key -> DRead : base
138+ OAuthToken -> DRead : base
138139 -- FIXME: Add numeric cases
139− _ -> [DRead, DNum, DIntegral, DReal] <> enum
140+ _ -> [DRead, DNum, DIntegral, DReal] <> enum
140141
141142 props ds x = intersect ds <$> getDerive x
142143
gen/src/Gen/Syntax.hs+5−3
@@ -97,10 +97,12 @@ verbAlias n m
9797 let t = terminalType (_type (_pParam x))
9898 n = sing (local k)
9999 in case _pLocation x of
100+ Header | local k == "oauth_token"
101+ -> Just $ TyApp (TyApp (TyCon "Header") (sing "Authorization")) t
100102 Query | x ^. iRepeated
101− -> Just $ TyApp (TyApp (TyCon "QueryParams") n) t
102− Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
103− Path -> Nothing
103+ -> Just $ TyApp (TyApp (TyCon "QueryParams") n) t
104+ Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
105+ Path -> Nothing
104106
105107 media :: [Type]
106108 media | Just b <- _mRequest m
gen/src/Gen/Types/Schema.hs+1
@@ -54,6 +54,7 @@ newtype Fix f = Fix (f (Fix f))
5454data Location
5555 = Query
5656 | Path
57+ | Header
5758 deriving (Eq, Show)
5859
5960deriveJSON options ''Location