Skip to content

Commit

Permalink
Clean ->swagger-data function
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsvalente committed Sep 13, 2023
1 parent 52be362 commit a50b13d
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/xiana/swagger.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
(def start-one 1)

(defonce all-methods
[:get :patch :trace :connect :delete :head :post :options :put])
#_[:get :patch :trace :connect :delete :head :post :options :put]
[:get :post])

(defn xiana-route->reitit-route
"xiana-route->reitit-route is taking route entry of our custom shape of routes
Expand Down Expand Up @@ -223,7 +224,7 @@
((if render?
#(routes->swagger-data % :route-opt-map route-opt-map)
identity))
((cond
((cond
(= type :json) json/write-value-as-string
(= type :edn) identity
:else identity))))
Expand All @@ -238,34 +239,20 @@

(defn ->swagger-data
"Update routes for swagger data generation."
;;; vv maybe remove optional parameter here, because it is unused somehow!!!
[config & {routes :routes
internal? :internal?
render? :render?
type :type
route-opt-map :route-opt-map
:as m}]
[config]
(let [internal? true

Check warning on line 243 in src/xiana/swagger.clj

View workflow job for this annotation

GitHub Actions / clj-kondo check

src/xiana/swagger.clj#L243

[unused-binding] unused binding internal?
render? true
type (or type :json)
type :json
config (update-in config [:xiana/swagger :data] eval)
route-opt-map {:data (or (get-in config [:xiana/swagger :data])
route-opt-map)}
config (update-in config [:xiana/swagger :data] (constantly route-opt-map))]
;;; ^^ this could be (assoc-in config [:xiana/swagger :data] route-opt-map) ??
;;; it is adding nothing at all to config just eval the [:xiana/swagger :data]
;;; only if :data must be a fn now it is doing something
route-opt-map {:data (get-in config [:xiana/swagger :data])}
config (assoc-in config [:xiana/swagger :data] route-opt-map)]
(if (swagger-configs-there? config)
(let [routes (or routes
(get config :routes []))
routes (if internal?
(apply conj routes (->default-internal-swagger-endpoints config))
routes)
(let [routes (get config :routes)
routes (apply conj routes (->default-internal-swagger-endpoints config))
routes-swagger-data (routes->swagger-json routes
:type type
:render? render?
:route-opt-map route-opt-map)
#_"TODO: [@LeaveNhA] You can't just place not-found value."
config-key (get-in config [:xiana/swagger :path] :swagger.json)]
(-> config
(assoc config-key routes-swagger-data)
Expand Down

0 comments on commit a50b13d

Please sign in to comment.