Skip to content

[Question]: Generate Example from nested object #2437

@davidjungman

Description

@davidjungman

Version

4.36.1

Question

I'm using Symfony 7.1. and NelmioApiDocBundle.

I'm struggling with having Request Body as DTO, where one of it's attributes is array of objects or native enums.
In this case, nelmio renders correctly the scheme, but is unable to create the examples.

I'd expect it to be able to get enum value and use one of it as example.

Is this functionality supported or not ? Thank you.

Additional context

/**
* @param Role[] $permissions
*/
public function __construct(
        #[Assert\NotBlank]
        public string $displayName,
        #[Assert\NotBlank(allowNull: true)]
        public ?string $description,
        #[Assert\NotBlank]
        public EntityId $parent,
        #[Assert\Valid]
        public array $permissions = [],
    ) {
    }
enum Role: string
{
    case ROLE_ADMIN = 'ROLE_ADMIN';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions