ring-swagger

ring-swagger & compojure-api
ikitommi 2018-09-11T05:09:42.000100Z

@alexkeyes googling on the js error could help?

vuuvi 2018-09-11T14:26:07.000100Z

ok, was just checking in here to see if anyone had seen that error before. I’ll update the thread here when I figure out what the error is

1👍
mgrbyte 2018-09-11T08:50:54.000100Z

thanks for looking, really appreciate your input and help :thumbsup:

mgrbyte 2018-09-11T09:43:33.000100Z

just been reading spec-tools sources, looks like this has already been considered, as there's fail-on-extra-keys-type-decoders in addition to strip-extra-keys-decoders. Although there's a TODO that makes e wary of directly using that: https://github.com/metosin/spec-tools/blob/master/src/spec_tools/transform.cljc#L113 Out of curiosity, what's the rationale why strip variant was chosen as default for c-api? I think it's great to be able to take request data, convert to EDN/clojure and run it through the spec at the repl; I've been assuming that giving a parameter spec as the metadata for :body-params or :parameters would codify the validity of the request/response, the stripping of extra-keys seems to break that invariant? thanks!

mgrbyte 2018-09-11T09:57:01.000100Z

erk, my bad (not= fail-on-extra-keys anything-to-do-with-stripping)

mgrbyte 2018-09-11T10:10:46.000100Z

fwiw, I've "fixed" this by: https://github.com/mgrbyte/capi-spec-transforms/commit/47736063b20a1c373140cbaea98acdc6d59a1e54 Hopefully that is "idiomatic" (for some value of idiomatic! :thinking_face:)

ikitommi 2018-09-11T13:04:39.000100Z

@mgrbyte The fix looks good.

ikitommi 2018-09-11T13:06:18.000100Z

about the default of dropping keys… there was a discussion about the default long time ago. Can’t recall why that was chosen. I think at least the option to pass-through all values easy to do. Would you like to do a PR where the spec-coercion could be easily modified to do any of the: strip, fail or nothing?

ikitommi 2018-09-11T13:06:43.000100Z

still alpha, so we can re-visit the decision too.

mgrbyte 2018-09-11T13:09:32.000100Z

I will look into doing a PR, possibly this evening. think if it's easy to change, that'd be good. I think the default should be "less surprise" - guessing for folks who are using spec that'd mean not dropping keys, but 🤷

ikitommi 2018-09-11T13:11:44.000100Z

there is also https://github.com/bhauman/spell-spec that could be used, haven’t tested that with spec-tools yet.

vuuvi 2018-09-11T14:26:07.000100Z

ok, was just checking in here to see if anyone had seen that error before. I’ll update the thread here when I figure out what the error is

1👍
mgrbyte 2018-09-11T15:52:01.000100Z

thanks for the links there.

mgrbyte 2018-09-11T15:52:17.000100Z

So it looks like my custom coercion wasn't good enough/the complete story

mgrbyte 2018-09-11T15:52:36.000100Z

Now values are not being transformed 😞

mgrbyte 2018-09-11T15:53:22.000100Z

keywords within map spec specifically

mgrbyte 2018-09-11T15:53:57.000100Z

I'm guessing I have to (re)implement the entire Coercion protocol?

ikitommi 2018-09-11T15:54:08.000100Z

keyword leaf values?

mgrbyte 2018-09-11T15:55:41.000100Z

yeah

ikitommi 2018-09-11T15:56:12.000100Z

the leaf specs need to be "decodable", which means Spec Records fow now. there are versions in soec-tools.spec for most/all predicates

mgrbyte 2018-09-11T15:56:14.000100Z

this works when I use :coercion :spec in api

ikitommi 2018-09-11T15:56:30.000100Z

e.g. spec-tools.spec/keyword?

ikitommi 2018-09-11T15:56:43.000100Z

Oh, hmm.

mgrbyte 2018-09-11T15:57:20.000100Z

I can switch between the new custom coercion and the default (`:spec`) and observe the transform works in the later, but not the former

mgrbyte 2018-09-11T15:57:40.000100Z

restarting the app in between of course

ikitommi 2018-09-11T15:57:46.000100Z

thats weird.

ikitommi 2018-09-11T15:58:30.000100Z

Could you pr the curent status into the repo?

mgrbyte 2018-09-11T15:58:49.000100Z

the example repo or my "real" app?

mgrbyte 2018-09-11T15:59:19.000100Z

will try and dup in the example repo, less to look at

mgrbyte 2018-09-11T16:07:02.000100Z

have to get a 🚌 home now, but will be looking again later tonight to see what I can do. thanks again for taking interest! 😍

ikitommi 2018-09-11T16:31:30.000100Z

https://github.com/mgrbyte/capi-spec-transforms/pull/1

Sid 2018-09-11T19:23:23.000100Z

we have setup a kong gateway for our stack.... how do we modify the swagger-ui to include the gateway uri in the hit to the service? i.e. request must be made out to https://domainname/Konguri/api instead of https://domainname/api as it does now....

ikitommi 2018-09-11T20:01:04.000100Z

@sidiv14.it you can set :basePath to swagger spec.