我一直沒能得到以下產生任何結果:swagger-jaxrs @ApiModelProperty AllowableValues是否可以與「range [x,y]」一起使用?
@ApiModelProperty(allowableValues = "range[0,8]", required = true)
private String myfield;
這工作:
@ApiModelProperty(allowableValues = "Email, Post", required = true)
private String multiValField;
併產生(在UI):
multiValField(string) = ['Email' or ' Post']
我可能會誤讀文檔,這是來自ApiModelProperty中的javadoc:
要設置一系列值,請以「範圍」開始值,方括號周圍的值包括最小值和最大值。 例如:範圍[1,5]。要設置最小/最大值,請使用 與範圍相同的格式,但使用「infinity」或「-infinity」作爲第二個值 。例如,範圍[1,∞,表示該參數的 允許的最小值爲1
我找不到人做任何的例子,雖然它看起來這將是常見的。我確實在@ApiParam的modules/swagger-jaxrs/src/test/scala/testresources/ResourceWithReturnTypes.java中找到了這個,但是我無法在我的GET端點上正常工作。
@ApiParam(value = "sample param data", required = true,
allowableValues = "range[0,10]")
@DefaultValue("1") @QueryParam("id") String id) {
有沒有人有這個工作的一些版本?
好吧,我現在檢查一下scala-oauth-authorization-server項目,看看我能否發現任何差異。謝謝羅恩。 – javatestcase 2015-01-12 20:45:09
我運行了項目,我可以確認它是在api-docs的輸出{「id」:{「type」:「integer」,「format」:「int64」,「description」:「寵物的唯一標識符」 ,「minimum」:「0.0」,「maximum」:「100.0」},但我在swagger-ui中看不到結果。 「id(整數):寵物的唯一標識符」,是一個已知的問題嗎? – javatestcase 2015-01-12 21:03:40
它可能從未實現過。 Swagger 2.0中的驗證範圍更廣泛,因此它有更好的機會被引入到新的swagger-ui中。隨意打開一個關於它的問題。 – Ron 2015-01-13 06:06:26