Basically, whenever swagger determines (incorrectly) that a property is read-only due to a lack of setters on a model class (see #2169), there appears to be no way to mark it otherwise.
Example
@ApiModel("foo")
public class Foo
{
private final int bar;
@JsonCreator
public Foo(@JsonProperty("bar") int bar)
{
this.bar = bar;
}
@JsonGetter("bar")
@ApiModelProperty(value = "some description", readOnly = false)
public int getBar(){return 0;}
}
This class is immutable, but Jackson handles serialization/de-serialization just fine.
Unfortunately, for the API spec we get:
"foo" : {
"type" : "object",
"properties" : {
"bar" : {
"type" : "integer",
"format" : "int32",
"description" : "some description",
"readOnly" : true
}
}
}
So basically, right now the situation is that if you use immutable model classes you're pretty much just screwed with no workaround.
Ideally #2169 will get fixed, but at the very least I would suggest at the very least that @ApiModelProperty#readOnly() be honored.
Basically, whenever swagger determines (incorrectly) that a property is read-only due to a lack of setters on a model class (see #2169), there appears to be no way to mark it otherwise.
Example
This class is immutable, but Jackson handles serialization/de-serialization just fine.
Unfortunately, for the API spec we get:
So basically, right now the situation is that if you use immutable model classes you're pretty much just screwed with no workaround.
Ideally #2169 will get fixed, but at the very least I would suggest at the very least that
@ApiModelProperty#readOnly()be honored.