symfonydoctrineswaggernelmioapidocbundle

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."
}

I already tried clearing cache both symfony and my vm but still no luck.

I hope someone is familiar with whats wrong here and point me to the right direction. Thanks.


Solution

  • Nelmio trying to generate documentation for your entity(User), and it can't understand what type of array item do you have in field roles. Nelmio also offer you example of required annotation string[]. So you need replace

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

    by

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