Fork me on GitHub
#ring-swagger
<
2017-04-24
>
lambder16:04:09

having the following code:

(s/defschema A
  {
   :a s/Str
   :b s/Int
   })

(s/defschema B
  {
   :x s/Str
   :y s/Int
   })

(s/defschema R
  (s/either A B))

(POST "/api" []
      :return s/Any
      :body [r R]
      (ok r))
the parameters of the /api endpoint according to http://localhost:3000/swagger.json are:
"parameters": [
                    {
                        "in": "body",
                        "name": "R",
                        "description": "",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/A"
                        }
                    }
                ], ...
why the schema is “#/definitions/A” not “#/definitions/R” ???

plins17:04:13

is there a smart way to log EVERY incoming request? i'm looking at https://github.com/pjlegato/ring.middleware.logger but this line is confusing me: (jetty/run-jetty (logger/wrap-with-logger my-ring-app) {:port 8080})

mtkp18:04:19

you can add that middleware to compojure-api's middleware config, or you can wrap it around your defapi and point ring to the wrapped function

mtkp18:04:01

in that example, replace my-ring-app with your defapi var