This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-18
Channels
- # admin-announcements (7)
- # arachne (24)
- # beginners (40)
- # boot (24)
- # braid-chat (22)
- # cider (8)
- # cljsrn (35)
- # clojure (32)
- # clojure-austin (1)
- # clojure-belgium (52)
- # clojure-russia (16)
- # clojure-sanfrancisco (1)
- # clojure-taiwan (2)
- # clojure-uk (25)
- # clojurescript (112)
- # core-async (3)
- # cursive (18)
- # data-science (1)
- # datascript (7)
- # datomic (30)
- # devcards (2)
- # dirac (12)
- # emacs (4)
- # flambo (1)
- # funcool (5)
- # hoplon (146)
- # jobs (9)
- # jvm (5)
- # off-topic (4)
- # om (141)
- # onyx (22)
- # re-frame (89)
- # reagent (86)
- # ring-swagger (31)
- # rum (3)
- # spacemacs (1)
- # specter (10)
- # untangled (112)
- # yada (3)
Hi, is there a way to add a entries to the responses
map in the generated swagger.json
?
AWS API Gateway wants explicit definitions of status code 200
(and probably 302
as well) and the auto-generation creates only default
, which AWS ignores.
So for now, I’m post-processing the generated JSON, but I can hardly imagine an uglier way to do this.
Also, :return
should set :responses 200
Thanks @juhoteperi – I will try this.
You could use s/Any
if you don't want or can't specify Schema
I’ve added
:responses { 200 {:schema s/Any}
302 {:schema s/Any}}
and I’m still getting the same result.Hmm, are you using latest Compojure-api?
:responses { 200 {:schema s/Any :description "Default response"}
302 {:schema s/Any :description "Redirect to `continue` location”}}
Now that I'm looking at the test, I'm not sure if it correctly checks the generated swagger docs
Though this test checks that swagger spec is correct: https://github.com/metosin/compojure-api/blob/master/test/compojure/api/integration_test.clj#L859-L869
That does not do it for me: https://github.com/trieloff/excelsior/blob/lambda-deploy/src/excelsior/handler.clj#L85
(GET "/plus" []
:responses {200 {:schema {:result s/Int} :description "Default response"}
302 {:schema s/Any :description "Redirect to `continue` location"}}
:query-params [x :- Long, y :- Long]
:summary "adds two numbers together"
(ok {:result (+ x y)}))
@darean the :swagger
value is evaluated at compile-time, could be promoted to run-time, what do you think?
I think the resource
would work nicely in here. It doesn’t support the same destructuring as normal routes, but it’s fully data driven.
(context "/:sheet/:cell" []
(resource
{:get {:responses {200 {:schema s/Any :description "Default response"}
302 {:schema s/Any :description "Redirect to `continue` location"}
500 {:schema {:code String} :description "Horror"}}
:parameters {:query-params {:speadsheet String
:continue String}
:path-params {:sheet Long
:cell String}}
:summary "Calculate response value from Redirect"
:swagger aws-gateway-options
:handler (fn [request]
...)}}))
there is more on the wiki (https://github.com/metosin/compojure-api/wiki/Resources-and-Liberator)