NelmioApiDocBundle: When using the option models: use_jms: false this result to this error:

NelmioApiDocBundle: When using the option models: use_jms: false this result to this error:

{
  "code": 500,
  "message": "Property \"App\Entity\User:roles\" is an array, but no indication of the array elements are made. Use e.g. string[] for an array of string."
}

我已经尝试清除 symfony 和我的虚拟机的缓存,但仍然没有成功。

我希望有人熟悉这里的错误并指出正确的方向。谢谢

Nelmio 正在尝试为您的实体(用户)生成文档,但它无法理解您在字段角色中拥有什么类型的数组项。 Nelmio 还为您提供了所需注释的示例 string[]。 所以你需要替换

/**
 * @var array
 */
protected $roles;

来自

/**
 * @var string[]
 */
protected $roles;