Romper
Romper

Reputation: 2257

Springfox integration with jackson

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;
    }
}

Both are showed as required, api.json:

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

@Size is not working, in api.json

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

but must be

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

What I should add to work properly?

I am using compile group: "io.springfox", name: "springfox-swagger2", version: "2.6.1"

Upvotes: 0

Views: 646

Answers (1)

Rafael Manzoni
Rafael Manzoni

Reputation: 617

I check this problem as an issue in the springfox github project:

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

That´s a issue about size annotation that has been resolved in springfox-swagger2 (2.3.1).

Upvotes: 0

Related Questions