swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

REOPEN #1855

Open honza-zidek opened this issue 4 years ago • 2 comments

Please reopen https://github.com/swagger-api/swagger-core/issues/1855. The bug is still present.

None of the all possible combinations I could think about gives the expected result, and most of them even do not produce a valid JSON :( And if the JSON is valid, then the example is missing.

This is the expected result:

{
    "aaa": ["value1", "value2"]
}

This is what I tried:

@ApiModelProperty(dataType="List", example = "'[''{''value1''}','{''value2''}'']")
private List<String> aaa01;

@ApiModelProperty(dataType="List", allowableValues = "value1, value2", allowEmptyValue = false)
private List<String> aaa02;

@ApiModelProperty(dataType="List", allowableValues = "value1, value2", allowEmptyValue = true)
private List<String> aaa03;

@ApiModelProperty( allowableValues = "value1, value2", allowEmptyValue = false)
private List<String> aaa04;

@ApiModelProperty(allowableValues = "value1, value2", allowEmptyValue = true)
private List<String> aaa05;

@ApiModelProperty(dataType = "List", example = "value1, value2, value2")
private List<String> aaa06;

@ApiModelProperty(dataType = "[Ljava.lang.String;", example = "value1, value2, value2")
private List<String> aaa07;

@ApiModelProperty(dataType = "[Ljava.lang.String;")
private List<String> aaa08;

@ApiModelProperty(dataType="[Ljava.lang.String;", example = "'[''{''value1''}','{''value2''}'']")
private List<String> aaa09;

@ApiModelProperty(dataType="[Ljava.lang.String;", allowableValues = "value1, value2", allowEmptyValue = false)
private List<String> aaa10;

@ApiModelProperty(dataType="[Ljava.lang.String;", allowableValues = "value1, value2", allowEmptyValue = true)
private List<String> aaa11;

This is what I get:

{
  "aaa01": "'[''{''value1''}','{''value2''}'']",
  "aaa02": {},
  "aaa03": {},
  "aaa04": [
    "string"
  ],
  "aaa05": [
    "string"
  ],
  "aaa06": "value1, value2, value2",
  "aaa07": "value1, value2, value2",
  "aaa08": [
    "string"
  ],
  "aaa09": "'[''{''value1''}','{''value2''}'']",
  "aaa10": [
    "string"
  ],
  "aaa11": [
    "string"
  ]
}

honza-zidek avatar Jan 25 '21 12:01 honza-zidek

Can confirm, with Springfox 3.0.0 the issue still exists contrary to the explanation on the bottom of #1855

MartinWeise avatar Mar 31 '21 14:03 MartinWeise

Can't beleive it's still not done! Moreover: ApiModelProperty should not only support lists, but it should support any valid JSON/Object!

dims12 avatar Apr 27 '22 13:04 dims12