I am using glassfish 4.1.1 and have integrated Swagger API documentation using the swagger 1.6.6 library.
I have a base class that looks something like this:
@ApiModel(value = "long")
public abstract class MyBaseClass {
...
private long value;
@JsonValue
public long getValue() {
return value;
}
public long getMaxValue(){
return 999999999;
}
public long getMinValue(){
return 999999999;
}
}
Also I have classes that inherit this base class which look something like this:
public class MyClass extends MyBaseClass {
......
public MyClass(long value) {
....
}
public static MyClass Empty = new MyClass();
}
I expect the result to look like this:
{
MyClass: "String"
}
but I get the following result:
"MyClass": {
"minValue": 0,
"maxValue": 0,
"empty": true
}
I have tried putting the @ApiModelProperty annotation on the field as well as the method, and in both cases the required field is respected, but the dataType field is ignored. I have also tried using "String", "string", and "java.lang.String" for the dataType but none of those have worked. I read a similar post How to set @ApiModelProperty dataType to String for Swagger documentation but it uses springfox and (Swagger 3.0). I am using swagger 1.6.6
Please tell me where which property can be configured to get the required result?
Might be useful to someone. In the end, in the class in which I use this type I put the @ApiModelProperty(dataType="string") anatomy everywhere,
MyApiClass{
@ApiModelProperty(dataType="string")
public MyClass var;
}
the result began to look as it should:
{
MyClass: "String"
}
but this is not quite what I needed. I was looking for a solution where I don't have to put @ApiModelProperty(dataType="string") everywhere when using this type.