2017-03-20 198 views
0
import javax.validation.constraints.Size; 

class User { 
    @Size(min = 3) 
    private String name; 

    private String email; 

    @JsonCreator 
    public User(@JsonProperty(value = "name", required = true) String name, 
       @JsonProperty(value = "email") String email) { 
     this.name = name; 
     this.email = email; 
    } 
} 

兩個Springfox集成的顯示要求,api.json:與傑克遜

{"type":"object","required":["email","name"],"properties":{"name":{"type":"string"},"email":{"type":"string"}}} 

@Size不工作,在api.json

"email":{"type":"string"} 

但必須

{ 
    "type": "string", 
    "minLength": 2 
} 

我應該添加什麼才能正常工作?

我使用編譯組: 「io.springfox」,名稱: 「springfox-swagger2」 版本: 「2.6.1」

回答

0

我檢查這個問題,因爲在springfox GitHub上項目的問題:

https://github.com/springfox/springfox/issues/987

這是一個關於在springfox-swagger2(2.3.1)中解決的大小注釋問題。

+0

我正在使用編譯組:「io.springfox」,名稱:「springfox-swagger2」,版本:「2.6.1」 – Romper

+0

這可能是問題依然存在。我建議你爲這個問題開一個問題。 –