JaxRs アノテーション付きサービスに Swagger アノテーションを追加しています。
私は次のものを持っています:
(^{
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!"})]}
}
生成されたクラスを逆コンパイルすると、注釈は次のようになります。
@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)
最初の注釈コード = 200L であることに注意してください
実行時には、この値は int でなければならず、これを実現する方法がわかりません
私が試したら
ApiResponses {:value [(ApiResponse {:code (int 200) :message "yay!"})]}
コンパイル エラーが発生します (maven swagger プラグインを使用)
Exception in thread "main" java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class, compiling:(pocclj/resourceclj.clj:14)
私が試してみました
(def success (int 200))
...
ApiResponses {:value [(ApiResponse {:code success :message "yay!"})]}
このコンパイルエラーが発生します:
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported annotation value: success of class class java.lang.Integer, compiling:(pocclj/resourceclj.clj:14)
私は他の多くのもの(derefなど)を試しましたが、秘密のソースを見つけることができません.
私はclojureにかなり慣れていないので、これに関する助けを切望しています。
前もって感謝します
マーティン