ring-swagger

ring-swagger & compojure-api
bja 2017-11-14T15:49:45.000584Z

tbh, I use compojure-api so I don't have to write a swagger.json file

bja 2017-11-14T15:50:11.000566Z

I expressed that opinion on HN and was astounded to learn that there are people who write that file by hand

petr.mensik 2017-11-14T15:57:47.000297Z

I would like to create my own metadata handler named :filter which would extract common filters from query-params so I don't have to repeat it in every GET endpoint. However I got stucked on No method in multimethod 'restructure-param' for dispatch value: :filter

(defmethod restructure-param :filter
  [_ binding acc]
  (update-in acc [:letks] into [binding `(:query-params ~'+compojure-api-request+)]))

jumar 2017-11-14T15:59:00.000028Z

you have :filters instead of :filter in your defmethod

petr.mensik 2017-11-14T15:59:46.000212Z

typo, I've edited it - it's not working anyway

jumar 2017-11-14T16:18:56.000100Z

I guess you should use proper namespace compojure.api.meta: https://github.com/metosin/compojure-api/wiki/Creating-your-own-metadata-handlers#example

petr.mensik 2017-11-14T16:22:49.000093Z

[compojure.api.meta :refer [restructure-param]] that's what I am using 🙂

ikitommi 2017-11-14T16:34:46.000368Z

do you have the ns with the custom restructuring imported from all namespaces where it is used? mms have global state.

ikitommi 2017-11-14T16:37:34.000331Z

having that code evaluated once before any routes are resolved works. But with tools-refresh & repl, the multimethod can end up in a dirty state.

ikitommi 2017-11-14T16:38:23.000274Z

would be cool If clojure had scoped mms & protocols.

petr.mensik 2017-11-14T19:54:48.000023Z

@ikitommi yes, that solved it, thanks a lot 🙂

👍 1