ring-swagger

ring-swagger & compojure-api
jmckitrick 2018-03-21T13:33:20.000743Z

Another question. In swagger-ui, there’s a column for ‘description’ for each of the parameters. How can I get a value into that column for each parameter?

jmckitrick 2018-03-21T15:02:28.000764Z

I saw that, but does it work with spec, @ikitommi?

ikitommi 2018-03-21T15:04:13.001016Z

no. spec uses spec-tools, which has the new syntax. I believe it reads the :json-schema/description field.

ikitommi 2018-03-21T15:04:20.000101Z

so, something like:

ikitommi 2018-03-21T15:04:44.000679Z

(st/spec
  {:spec integer?
   :name "integer"
   :description "it's an int"
   :json-schema/default 42})

ikitommi 2018-03-21T15:05:26.000113Z

actually, it reads the :description and merges :json-schema/* things on top.

jmckitrick 2018-03-21T15:05:35.000072Z

Ah, ok.

ikitommi 2018-03-21T15:05:35.000369Z

Schema will get same api, soon.

ikitommi 2018-03-21T15:06:24.000932Z

e.g.

(schema-tools.core/schema
  {:schema s/Int
   :description "it's an int"})

(spec-tools.core/schema
  {:spec int?
   :description "it's an int"})

jmckitrick 2018-03-21T15:07:03.000207Z

Perfect. I’ll try it out shortly

ikitommi 2018-03-21T15:07:09.000139Z

we are porting all the stuff from ring-swagger int schema-tools (and polish things), will also work with ClojureScript, which is kinda awesome 🙂

jmckitrick 2018-03-21T15:07:35.000868Z

Very cool!

jmckitrick 2018-03-21T15:07:50.000796Z

I want to help with the docs as well.

ikitommi 2018-03-21T15:08:42.000519Z

that’s really good. the auth docs… many people have been asking about ready integration into auth via buddy. We have had many versions of those, but nothing that could have been pushed to c-api.

ikitommi 2018-03-21T15:10:12.000674Z

Thanks to Colin, Cursive does static analysis on all the c-api macros, could be those too. But super busy with a project and with all the libs, don’t have extra time to do those. Feel free to suggest something 🙂

jmckitrick 2018-03-21T15:11:24.000501Z

My first question is what needs to be documented for c-api that isn’t covered by the existing buddy docs?

jmckitrick 2018-03-21T15:11:36.000662Z

It makes sense to just add links to the example projects with buddy to start.

ikitommi 2018-03-21T15:12:42.000634Z

yes, that would be a good start.

ikitommi 2018-03-21T15:15:29.000891Z

some people have used custom keys meta-data like :roles to mark who can access the routes. and :user to bind the buddy user. Not sure is that a good idea to have those in c-api itself.

ikitommi 2018-03-21T15:15:40.000836Z

it’s between a library and a monolith.

fingertoe 2018-03-21T19:18:40.000820Z

still kinda stuck on this - I am using compojure.api.sweet when I access it from ClojureScript I get No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ’http://localhost:8080' is therefore not allowed access. Where do I fix that in the compojure-api.sweet setup?

juhoteperi 2018-03-21T19:26:51.000406Z

@fingertoe If you want to access make http requests from one origin to another, you need to enable CORS headers, you can use: https://github.com/r0man/ring-cors

juhoteperi 2018-03-21T19:28:02.000195Z

Like from localhost to http://example.com, or probably from localhost:3000 to localhost:8080, in latter case it is probably better choice to also serve the Cljs app from same origin as the API so there is no need for CORS

fingertoe 2018-03-21T19:38:12.000657Z

Good deal. I will give it a go. There is a lot to learn!

jmckitrick 2018-03-21T20:25:57.000659Z

@ikitommi So if user and roles shouldn’t be in c-api, where would be a better place?