on develop help sign in
Moving oauth_token into an Authorization header
df4f01eBrendan Hay
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
110 g ml p
110 g ml p
111
111
112globalParam :: Local -> Param (Fix Schema) -> AST (Param Global)
112globalParam :: Local -> Param (Fix Schema) -> AST (Param Global)
113−globalParam l p = ($ p) $ case l of
113+globalParam l p = case l of
114− "alt" -> overrideParam l (Alt alt)
114+ "alt" -> overrideParam l (Alt alt) p
115− "key" -> overrideParam l Key
115+ "key" -> overrideParam l Key p
116− "oauth_token" -> overrideParam l OAuthToken
116+ "oauth_token" -> overrideParam l OAuthToken (p & pLocation .~ Header)
117− _ -> localParam "" l
117+ _ -> localParam "" l p
118 where
118 where
119 alt = alternate $ fromMaybe "JSON" (p ^. iDefault)
119 alt = alternate $ fromMaybe "JSON" (p ^. iDefault)
120
120
gen/src/Gen/AST/Solve.hs+9−8
@@ -128,15 +128,16 @@ getDerive g = loc "getDerive" g $ memo derived g go
128 SObj _ (Obj _ ps) -> foldM props base (Map.elems ps)
128 SObj _ (Obj _ ps) -> foldM props base (Map.elems ps)
129
129
130 literal = \case
130 literal = \case
131− Text -> base <> [DRead, DOrd, DIsString]
131+ Text -> base <> [DRead, DOrd, DIsString]
132− Bool -> enum
132+ Bool -> enum
133− Time -> DRead : base
133+ Time -> DRead : base
134− Date -> DRead : base
134+ Date -> DRead : base
135− Body -> []
135+ Body -> []
136− Alt _ -> DRead : base
136+ Alt _ -> DRead : base
137+ Key -> DRead : base
137− Key -> DRead : base
138+ OAuthToken -> DRead : base
138 -- FIXME: Add numeric cases
139 -- FIXME: Add numeric cases
139− _ -> [DRead, DNum, DIntegral, DReal] <> enum
140+ _ -> [DRead, DNum, DIntegral, DReal] <> enum
140
141
141 props ds x = intersect ds <$> getDerive x
142 props ds x = intersect ds <$> getDerive x
142
143
gen/src/Gen/Syntax.hs+5−3
@@ -97,10 +97,12 @@ verbAlias n m
97 let t = terminalType (_type (_pParam x))
97 let t = terminalType (_type (_pParam x))
98 n = sing (local k)
98 n = sing (local k)
99 in case _pLocation x of
99 in case _pLocation x of
100+ Header | local k == "oauth_token"
101+ -> Just $ TyApp (TyApp (TyCon "Header") (sing "Authorization")) t
100 Query | x ^. iRepeated
102 Query | x ^. iRepeated
101− -> Just $ TyApp (TyApp (TyCon "QueryParams") n) t
103+ -> Just $ TyApp (TyApp (TyCon "QueryParams") n) t
102− Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
104+ Query -> Just $ TyApp (TyApp (TyCon "QueryParam") n) t
103− Path -> Nothing
105+ Path -> Nothing
104
106
105 media :: [Type]
107 media :: [Type]
106 media | Just b <- _mRequest m
108 media | Just b <- _mRequest m
gen/src/Gen/Types/Schema.hs+1
@@ -54,6 +54,7 @@ newtype Fix f = Fix (f (Fix f))
54data Location
54data Location
55 = Query
55 = Query
56 | Path
56 | Path
57+ | Header
57 deriving (Eq, Show)
58 deriving (Eq, Show)
58
59
59deriveJSON options ''Location
60deriveJSON options ''Location