Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Generate Example from nested object #2437

Open
davidjungman opened this issue Jan 30, 2025 · 1 comment
Open

[Question]: Generate Example from nested object #2437

davidjungman opened this issue Jan 30, 2025 · 1 comment
Labels

Comments

@davidjungman
Copy link

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';
}
@davidjungman
Copy link
Author

EDIT:

The issue is somewhere else. As array with default [], nelmio shows it as [] in the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant