 
 (defn license-str [{:keys [:license]}]
   ;;Converts the license part of the info to a markdown table. Needs fixing
-  (let [{:keys [:name :url]} license]
+  (let [{:keys [name url] :or {url "N/A"}} license]
     (->> ""
          (str "| \n")
          (str (str " | " url))


(defn contact-str [{:keys [:contact]}]
  ;;Converts the contact part of the info to a markdown table. Needs fixing
  (let [{:keys [:name :url :email]} contact]
    (->> ""
         (str "| \n")
         (str (str " | " email))

    (.replaceAll "[ {]*:license [{](.*?)[}][,}]" (license-str info))
    ))

(defn update-comp [component {:keys [produces consumes]}]
  (clojure.pprint/pprint component)
  (api/update 
   (cond-> (api/map->Component component)
     produces (assoc :produces produces)
     consumes (assoc :consumes consumes)) client))

(defn create-methods [parent model description wid _id path [methods]]
  (-> (api/->Component methods description (str wid) _id (api/type-id-by-name model "Operation") (str (:_id parent))) 
      (api/create client))
  )

(defn create-resource [{:keys [paths]} workspace]
  ;;Create a resource. Does so by setting first path resource then adding the operations to it. Requires a full swagger file as input and the workspace it is being created in
  (let [model (find-or-create-model client)
        {:keys [_id description]} model
        wid (:_id workspace)]
    (map 
     (fn [[path methods]]
       (let [parent (-> (api/->Component path description (str wid) _id (api/type-id-by-name model "Resource") nil)
                        (api/create client))]
         ;; (map 
         ;;  (fn [[m]]
         ;;    (-> (api/->Component m description (str wid) _id (api/type-id-by-name model "Operation") (str (:_id parent)))
         ;;        (api/create client))) 
         ;;  methods)
         (map (partial create-methods parent model description wid _id path) methods)
         ))
     paths)))

(defn get-info [spec]
  ;Converts the info from a Swagger 2 map to a string - This method needs to be redone
  (let [{:keys [:info]} spec
        workspace (->> ""
             (str info)
             (json-to-markdown info)
             (create-workspace "tester" client)
             )]
    (create-resource spec workspace)))


(defn get-data [spec]
