I am adding Swagger annotations to JaxRs annotated services.
I have the following:
(^{ GET true Path "/{who}" ApiOperation {:value "Get a hello" :notes "simple clojure GET"} Produces ["text/plain; charset=UTF-8"] ApiResponses {:value [(ApiResponse {:code 200 :message "yay!"})]} }
If I decompile the created class, the annotations look like this:
@ApiResponses({@com.wordnik.swagger.annotations.ApiResponse(code=200L, message="yay!")}) @Produces({"text/plain; charset=UTF-8"}) @ApiOperation(value="Get a hello", notes="simple clojure GET") @Path("/{who}") @GET(true)
notes that in the first code annotations = 200L
At runtime, this value must be int, and I cannot figure out how to do this.
if i try
ApiResponses {:value [(ApiResponse {:code (int 200) :message "yay!"})]}
I get a compilation error (using the maven swagger plugin)
Exception in thread "main" java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class, compiling:(pocclj/resourceclj.clj:14)
I tried
(def success (int 200)) ... ApiResponses {:value [(ApiResponse {:code success :message "yay!"})]}
What causes a compilation error:
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported annotation value: success of class class java.lang.Integer, compiling:(pocclj/resourceclj.clj:14)
I tried a bunch of other things (deref, etc.) but couldn't find the secret sauce.
I am new to clojure and desperately need help for this.
Thanks in advance
Martin