WIP: show procs in OpenAPI description

Thanks @LogvinovLeon
This commit is contained in:
Joe Nelson
2016-09-08 21:23:16 -07:00
parent f3b79bcc40
commit f49c6aa0f3
4 changed files with 43 additions and 15 deletions
+11 -3
View File
@@ -95,12 +95,20 @@ decodeSynonyms cols =
<*> HD.value HD.text <*> HD.value HD.text
<*> HD.value HD.text <*> HD.value HD.text
accessibleProcs :: H.Query Schema [(Text, Text)]
accessibleProcs :: H.Query Schema [(Text, ProcDescription)]
accessibleProcs =
H.statement sql (HE.value HE.text) (HD.rowsList ((,) <$> HD.value HD.text <*> HD.value HD.text)) True
H.statement sql (HE.value HE.text)
(map addName <$> HD.rowsList (ProcDescription <$> HD.value HD.text
<*> HD.value HD.text
<*> HD.value HD.text)) True
where
addName :: ProcDescription -> (Text, ProcDescription)
addName pd = (pdName pd, pd)
sql = [q|
SELECT p.proname as "proc_name", pg_get_function_result(p.oid) as "return_type"
SELECT p.proname as "proc_name",
pg_get_function_arguments(p.oid) as "args",
pg_get_function_result(p.oid) as "return_type"
FROM pg_namespace n
JOIN pg_proc p
ON pronamespace = n.oid