Skip to content

[Bug]: Having named, nested Models ignores names from subsequent alternative name definitions #2757

Description

@querclemens

Version

5.10.3

Description

Defining nested alternative names in a random order will ignore alternative names of nested Models, and use auto-generated ones instead.
This happens because setting the alternative name immediately also registers the corresponding Model, in turn registering all nested Models, without before setting the subsequent model's alternative name.

Because of this, the following alternative name config:

models:
    names:
        - { alias: GrandChildSpecial, type: App\Entity\GrandChild, groups: ['special'] }
        - { alias: ChildSpecial, type: App\Entity\Child, groups: ['special'] }
        - { alias: ParentSpecial, type: App\Entity\Parent, groups: ['special'] }

will work as it did before 5.5.

But a re-ordered name definiton like this:

models:
    names:
        - { alias: ChildSpecial, type: App\Entity\Child, groups: ['special'] }
        - { alias: GrandChildSpecial, type: App\Entity\GrandChild, groups: ['special'] }
        - { alias: ParentSpecial, type: App\Entity\Parent, groups: ['special'] }

will have the GrandChildSpecial use the auto-generated GrandChildn(n) instead, since at this point the alternative name of the child Model was not known yet.

This was introduced in 5.6, with the alternative name refactor: https://github.com/nelmio/NelmioApiDocBundle/pull/2542/changes#diff-d4f02c49939937ce274a40f41f3e257e7fe594fb3c158060cce490c0e0b30a96R86

JSON OpenApi

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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