                                    :required :true}))]
     (reduce reducer swagger-object path-ids)))
 
+(defn reduce-schema-key
+  "Simplifies a key from a schema reducing it to a keyword, and whether the key is required or optional."
+  [schema-key]
+  (cond (s/optional-key? schema-key)
+        [(.k schema-key) false]
+
+        (s/required-key? schema-key)
+        [(.k schema-key) true]
+
+        (keyword? schema-key)
+        [schema-key true]
+
+        :else
+        (throw (RuntimeException. (format "No idea what to do with query schema key %s." schema-key)))))
+
 (defn default-query-params-injector
   "Identifies each query parameter via the :query-schema metadata and injects it."
   [swagger-options swagger-object routing-entry params-key]
   (if-let [schema (-> routing-entry :meta :query-schema)]
     ;; Assumes that the schema is a map.
-    (let [reducer (fn [so [key-id key-schema]]
-                    (cond-let
-                      ;; Just ignore these, they are a convinience for the caller ("be generous in what you accept").
-                      (= s/Any key-id)
-                      so
-
-                      [[k required] (cond (s/optional-key? key-id)
-                                          [(.k key-id) false]
-
-                                          (s/required-key? key-id)
-                                          [(.k key-id) true]
-
-                                          (keyword? key-id)
-                                          [key-id true]
-
-                                          :else
-                                          (throw (ex-info (format "No idea what to do with query schema key %s." key-id)
-                                                          {:routing-entry routing-entry
-                                                           :key-id        key-id
-                                                           :key-schema    key-schema})))]
-
-                      :else
-                      (update-in so params-key
-                                 conj {:name     k
-                                       :in       :query
-                                       :required required})))]
-      (reduce reducer swagger-object schema))
+    (try
+      (let [reducer (fn [so [key-id key-schema]]
+                      (cond-let
+                        ;; Just ignore these, they are a convinience for the caller ("be generous in what you accept").
+                        (= s/Any key-id)
+                        so
+
+                        [[k required] (reduce-schema-key key-id)]
+
+                        :else
+                        (update-in so params-key
+                                   conj {:name     k
+                                         :in       :query
+                                         :required required})))]
+        (reduce reducer swagger-object schema))
+      (catch Exception e
+        (throw (ex-info "Unable to convert routing entry into Swagger data."
+                        routing-entry
+                        e))))
     ; no :query-schema
     swagger-object))
 

  [swagger-options schema]
  ;; To be done!
  (medley/remove-vals nil?
                      {:required   []
                       :description (-> schema meta :doc)
                       :properties {}}))

(defn to-schema-reference
  "Converts a schema to a schema reference; the schema must be named.  Returns a tuple

        path-params-injector (:path-params-injector swagger-options default-path-params-injector)
        query-params-injector (:query-params-injector swagger-options default-query-params-injector)
        body-params-injector (:body-params-injector swagger-options default-body-params-injector)
        responses-injector (:responses-injector swagger-options default-responses-injector)
        params-key (concat paths-key ["parameters"])]
    (as-> swagger-object %
          (assoc-in % paths-key
