diff --git a/src/metabase/util/malli.clj b/src/metabase/util/malli.clj index d07648e627eda0667b0e837779ce03736d0a159b..30b2679599a585be30b013d049a4ad7ea8a1bbfb 100644 --- a/src/metabase/util/malli.clj +++ b/src/metabase/util/malli.clj @@ -70,7 +70,7 @@ explain-fn-fail! (str "Inputs: " (if single (pr-str (first (mapv :raw-arglist parglists))) (str "(" (str/join "\n " (map (comp pr-str :raw-arglist) parglists)) ")")) - "\n Return: " (str/replace (u/pprint-to-str (:schema return)) + "\n Return: " (str/replace (u/pprint-to-str (:schema return :any)) "\n" (str "\n ")) (when (not-empty doc) (str "\n\n " doc)))) diff --git a/test/metabase/util/malli_test.clj b/test/metabase/util/malli_test.clj index 908f1990cd50539024e4bcacf4d291ebb73c0780..5312f87a95231df10158bd02f500c7193a6d6fde 100644 --- a/test/metabase/util/malli_test.clj +++ b/test/metabase/util/malli_test.clj @@ -35,6 +35,55 @@ (is (str/ends-with? (:doc (meta #'boo)) "something very important to remember goes here")) (ns-unmap *ns* 'boo)) + (testing "no schemas given should work" + (mu/defn qux []) + (is (= "Inputs: []\n Return: :any" + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux) + (mu/defn qux "Original docstring." []) + (is (= (str/join "\n" + [ "Inputs: []" + " Return: :any" + " " + "" + " Original docstring."]) + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux)) + + (testing "no return schemas given should work" + (mu/defn qux [x :- :int]) + (is (= "Inputs: [x :- :int]\n Return: :any" + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux) + (mu/defn qux "Original docstring." [x :- :int]) + (is (= (str/join "\n" + [ "Inputs: [x :- :int]" + " Return: :any" + " " + "" + " Original docstring."]) + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux)) + + (testing "no input schemas given should work" + (mu/defn qux :- :int []) + (is (= "Inputs: []\n Return: :int" + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux) + (mu/defn qux :- :int + "Original docstring." + [x :- :int]) + (is (= (str/join "\n" + [ "Inputs: [x :- :int]" + " Return: :int" + " " + "" + " Original docstring."]) + (:doc (meta #'qux)))) + (ns-unmap *ns* 'qux)) + + + (testing "multi-arity, and varargs doc strings should work" (mu/defn ^:private foo :- [:multi {:dispatch :type} [:sized [:map [:type [:= :sized]]