ring-swagger

ring-swagger & compojure-api
2018-11-13T13:10:24.040900Z

@the 2) you can add a description in your api

2018-11-13T13:10:52.041400Z

(api
   {:swagger
    {:ui   "/swagger"
     :spec "/swagger.json"
     :data {:info                {:title       "xxx"
                                  :description "yyy"}

2018-11-13T13:11:37.042Z

3) Can’t you define a schema for the route? (defschema Article2 (dissoc Article description))?

2018-11-13T13:11:40.042200Z

something like that

thomash 2018-11-13T13:17:49.043600Z

@mping 2) I have one big defapi with many nested context. Would you use one api per context?

thomash 2018-11-13T13:18:56.044800Z

3) Yeah, that would probably work. I thought I could get away with on-the-fly schemas.

2018-11-13T13:18:58.044900Z

that may not work because in swagger, I only see one spot at the top for the description and title

thomash 2018-11-13T13:20:36.046200Z

swagger makes a nice section per context. This can have a top-level :description but this text is then used as a default description for the individual routes in the context, not as an "introductory" description.

2018-11-13T13:20:55.046600Z

you have summary per route

2018-11-13T13:21:06.047Z

and you also have tags

2018-11-13T13:21:29.047500Z

(GET "/rate" []
        :summary "Gets the rate for a given date, aggregated by confirmation date"

2018-11-13T13:21:41.048Z

tags are weird because description is in toplevel, but tags are in each context

thomash 2018-11-13T13:21:49.048200Z

yes, this is shown in the route heading (`:summary`), so it's per-route, not per-context.

2018-11-13T13:21:49.048300Z

(context "/metrics" []
      :tags ["ui"]
      :coercion :spec

2018-11-13T13:22:15.048900Z

(def swagger-api
  (api
   {:swagger
    {:ui   "/swagger"
     :spec "/swagger.json"
     :data {:info                {:title       " services"
                                  :description " services"}
          ...
            :tags                [{:name "processor", :description "migrations and event processor"}
                                  {:name "ui",        :description "ui services"}]

thomash 2018-11-13T13:22:20.049100Z

:tags are used as the context title in the api docs.

2018-11-13T13:22:24.049300Z

yep

2018-11-13T13:22:31.049600Z

I don’t know any other places other than that

thomash 2018-11-13T13:22:58.049900Z

ok, thanks for the effort anyway

2018-11-13T13:23:19.050200Z

np, feel free to check the openapi docs, maybe there’s something buried: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

thomash 2018-11-13T13:23:37.050500Z

ah, ok, will do that

ikitommi 2018-11-13T13:34:37.052200Z

@the the 3, defschema puts the Schema name, ns and description as meta-data for the Schema. normal dissoc retains the meta-data and the docs are wrong. there are helpers for these in https://github.com/metosin/schema-tools. e..f (-> Article (st/dissoc :description)))

thomash 2018-11-13T13:35:32.052800Z

great, thanks 👍

ikitommi 2018-11-13T13:36:23.053600Z

also things like st/select-keys, which understand the s/optional-key & s/required-key wrappings.