             [camel-snake-kebab.core :refer :all]))
 
 (defn generate-ns-declaration
-  "Generates the ns declaration for an API.
-  Takes name, version, description and docs link, all strings."
-  [name version desc docs-link]
+  "Generates the ns declaration for the given API model."
+  [{name :name
+    version :version
+    desc :description
+    docs-link :documentationLink}]
   `(~'ns
     ~(symbol (str "gogolica." name "." version)) ;; HACK: instead of having the ns as string, we should probably read it from the current one
-    ~(str desc "\n\nDocumentation link: " docs-link)
+    ~(str desc "\n\n"
+          "Documentation link: " docs-link)
     (:gen-class)
     (:require [gogolica.common :refer [~'?assoc ~'exec-http] :as ~'common]
               [clojure.string :as ~'str])))
 
-;; TODO move util generation to another function or a dedicated namespace
 (defn generate-global-vars
-  "Generates global variables that are used throughout the generated namespace"
-  [root-url service-path]
+  "Generates global variables that are used throughout the generated
+   namespace for the given API model"
+  [{root-url :rootUrl
+    service-path :servicePath}]
   `[(def ~'base-url ~(str root-url service-path))])
 
 (defn split-required-params

(defn generate-request
  "Generates the request map to be passed to the http library.
  NB: uses the `base-url` symbol, it should be generated in the ns including the method."
  [http-method path parameters]
  (let [query-params (->> parameters
                          (filter (fn [[_ v]] (= (:location v) "query")))
                          (mapv   (fn [[k _]] (name k))))

(defn generate-ns
  "Given a service model, generates a clojure namespace with the implementation
   of all the API methods as functions and returns it as a pretty string."
  [model]
  (let [ns-declaration (generate-ns-declaration model)
        global-vars (generate-global-vars model)
        functions (->> (:resources model)
                       (mapcat
                        (fn [[resource-id resource]]
