Fork me on GitHub
#ring-swagger
<
2017-01-09
>
metametadata08:01:46

@ikitommi looks promising! "application/yaml" coerce/query-schema-coercion-matcher looks suspicious 🙂 AFAIU, Yaml and Msgpack are similar to JSON but still have some differences, e.g. "YAML has many additional features lacking in JSON, including comments, extensible data types, relational anchors, strings without quotation marks, and mapping types preserving key order.". Whatever the library decision about coercion for these formats is it should be in the readme somewhere at the forefront. One of the solutions is to turn off coercion for additional formats altogether. I.e. make 1.2.0 fully support out-of-the-box only JSON, Transit and edn.

ikitommi14:01:26

@metametadata Thanks and good point about the YAML (and it’s application/x-yaml not application/yaml). I’ll write few tests and see how the two extra formats behave with & without coercion. With pre 1.2, a json-schema-coercion-matcher is used with all responses. Actually - the response coercion could be (constantly nil) for all. Responses are generated by handler, so all clojure types are available...

sickill19:01:24

does it make sense to use compojure-api for a website (mostly html responses, small amount of json endpoints) ?

sickill19:01:13

I love path/query/form params validation/coercion, pure compojure doesn't do this, so considering compojure-api for everything

sickill19:01:04

I don't see any reason to not do this, but there's one small thing which makes me wonder: -api in the name of the library 🙂

sickill19:01:29

(I'm already using compojure-api in an other API-only project)

sickill19:01:50

I'm wondering if it does stuff like for example adding some response headers (API security, content related etc) which make no sense for text/html responses?

ikitommi20:01:12

@sickill it's totally ok :) you can use the endpoint macros (`GET`...) also in plain ring/compojure-app, they don't have to be under api - they produce ring handler functions. Or you can add a undocumented subroute under api which has non-compojure-api routes (like ring asset handlers).

ikitommi20:01:56

if you GETs are outside of api, the reverse routing does not work and to read JSON/EDN you have to mount a request-formatter yourself.

ikitommi20:01:42

api does some extra stuff like injects the reverse route tree into request, but should not be harmfull to the static handlers.

ikitommi20:01:27

see the compojure.api.api & compojure.api.middleware source for details.

ikitommi20:01:34

hope this helps.

sickill20:01:53

@ikitommi awesome, thanks for the explanation

sickill20:01:11

reverse routing is very useful so I'd definitely want to preserve that

sickill20:01:58

I guess I'll just stick everything under (api ...)

sickill20:01:06

(it may be a bit misleading when read by other devs, but that's no biggie)

sickill20:01:14

maybe it would be worth to alias this macro to sth more generic?

sickill20:01:08

and going further this path... renaming compojure-api to compojure-awesomeness (just kidding :P)