swagger access-control-origin settings

现象

访问swagger时,提示

Can't read from server. It may not have the appropriate access-control-origin settings.

问题

@ApiModelProperty(name = "config", value = "extField",dataType = "String", required = true, example="{'name':'zx'}")
private String config;

这里的example,愿意是json字符串,但因为用单引号,所以导致swagger出不来。

解决

@ApiModelProperty(name = "config", value = "extField",dataType = "String", required = true, example="{\"name\":\"zx\"}")

private String config;

感想

这个问题排查了小半天,对swagger的这个报错需要吐槽一下,简直是文不对题。

你可能感兴趣的:(开发问题)