                    (when-not (.isDirectory f)
                      (let [spec (slurp f)
                            json-spec (parse-string spec true)
-                           swag (import-spec spec nil json-spec)]
-                       (update-spec spec nil swag json-spec)
+                           swag (import-spec spec nil json-spec f)]
+                       (update-spec spec nil swag json-spec f)
                        (c/delete swag client)))))))
 

          0
          paths))

(defn import-spec [spec wsname json-spec]  
  (let [swag (-> {:_id (api/get-spec client nil wsname nil spec nil)}
                 (c/map->Workspace)
                 (c/find-by-id client))]
    (testing "Workspace name"
      (is (= (:name swag) (:title (:info json-spec)))))
    (testing "Testing components in workspace"
      (is (= (count (:components swag))
             (count-components json-spec))))
     (testing "Testing references in workspace"
      (is (= (+ (count-references json-spec) 
                (count-securities (:paths json-spec)))
             (count (:references swag)))))
    swag))

(defn update-spec [spec wsname swag json-spec]
  (c/delete (c/map->Component {:_id (first (:components swag))}) client)
  (let [json-spec (assoc-in json-spec [:definitions :new-model] {:type "object"})
        json-spec (assoc-in json-spec [:definitions :sec-model] {:type "object"})

        swag (-> {:_id (api/get-spec client nil wsname nil spec nil)}
                 (c/map->Workspace)
                 (c/find-by-id client))]
    (testing (str "Workspace name for " f)
      (is (= (:name swag) (:title (:info json-spec)))))
    (testing (str "Testing components in updated workspace when importing " f)
      (is (= (count (:components swag))
             (count-components json-spec))))
    (testing (str "Testing references in workspace when importing " f)
      (is (= (+ (count-references json-spec) 
                (count-securities (:paths json-spec)))
             (count (:references swag)))))))
