Fork me on GitHub
#ring-swagger
<
2017-01-07
>
assoc-in01:01:08

Has anyone been able to get the authorization button for ring swagger from the demo for swagger ui (http://petstore.swagger.io/) ? I am looking through the docs and not sure how to get this to show up. I tried to add a :secuirtyDefinition to the defapi for swagger, but it doesn't seem to work. Do I need to make my own custom index.html page to have the authorize button?

metametadata14:01:32

So, apparently, to turn off coercions but leave validations in place one must use this:

(compojure.api.sweet/api
    {:coercion (fn validation-only
                 [_request]
                 (fn [_coercion-type]
                   (fn [_schema]
                     nil))) ...

ikitommi15:01:52

@metametadata does this work? :coercion (constantly (constantly nil))?

ikitommi15:01:18

“whatever request, whatever type, no matchers"

metametadata15:01:57

it should be :coercion (constantly (constantly (constantly nil))) 🙂

ikitommi15:01:10

ou, that 🙂

ikitommi15:01:36

btw, just did a PR out of the :body params (don’t keywordize keys), does that look right: https://github.com/metosin/compojure-api/pull/265

metametadata15:01:11

I need some time to scan through the diff..

ikitommi15:01:04

there is the one test to verify that. Updated ring-swagger to support non-keyworded map keys too.

metametadata15:01:32

I've spent some time today figuring out the coercion code. And I'm not sure but think there's a conceptual problem: the library by default applies json-*-matcher even though the input/output formats of my API is going to be Transit which doesn't require all the ceremony the "loosely-typed" JSON needs. So I'm now leaning towards turning off the coercion all together in my API and see how it goes.

metametadata15:01:06

and I also saw that it will addressed in the future

metametadata15:01:13

"The plan is to provide extendable protocol-based coercion out-of-the-box (Transit doesn't need any coercion, XML requires some extra love with sequences). Stay tuned."

metametadata15:01:22

^ somewhere in the wiki

ikitommi15:01:23

you are right on that. with 1.2, Muuntaja publishes the used in & out format into the request, so that could be used. Should be done by the c-api.

ikitommi15:01:59

would you like to do a PR out of that?

metametadata15:01:35

awesome! so it looks like the current patch just addresses the particular problem which will be fixed in a better way in the future

ikitommi15:01:02

e.g. change the default-coercion-matchers to read the used type and do coercion based on that.

metametadata15:01:34

unfortunately, I don't yet have enough time to do a PR

ikitommi15:01:52

created a issue out of that, tagged for 1.2: https://github.com/metosin/compojure-api/issues/266

ikitommi15:01:09

off to sauna 🙂

metametadata15:01:14

I've updated the wiki with the example of turning off coercion and added a link to this new issue: https://github.com/metosin/compojure-api/wiki/Validation-and-coercion