NelmioApiDocBundle icon indicating copy to clipboard operation
NelmioApiDocBundle copied to clipboard

[Bug]: Lost data format in schema for array of objects

Open p-golovin opened this issue 10 months ago • 1 comments

Version

4.25.2

Description

Lost data format in schema for array of objects.

Old schema:

          "contestants": {
            "title": "List of contestants",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatContestant2"
            }

...

      "StatContestant2": {
        "required": [
          "members",
          "name",
          "type",
          "side"
        ],
        "properties": {
          "members": {
            "title": "Teams",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatMember2"
            }
          },
          "name": {
            "title": "Name",
            "type": "string"
          },
          "type": {
            "title": "Type of contestant",
            "type": "string",
            "enum": [
              "player",
              "team",
              "pair"
            ]
          },
          "side": {
            "title": "Side of contestant",
            "type": "string",
            "enum": [
              "home",
              "away"
            ]
          },
          "outcome": {
            "title": "Outcome result for contestant in game",
            "type": "string",
            "enum": [
              "lose",
              "win",
              "tie"
            ],
            "nullable": true
          },
          "country": {
            "title": "Country",
            "nullable": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/Country2"
              }
            ]
          }
        },
        "type": "object"
      },

New schema:

          "contestants": {
            "$ref": "#/components/schemas/StatContestant[]2"
          },

...

      "StatContestant[]2": {
        "type": "object"
      },

Documents are:

    /**
     * List of contestants
     *
     * @var Collection<array-key, StatContestant>
     */
    #[Groups(['game:list'])]
    #[Assert\NotBlank]
    #[ODM\EmbedMany(targetDocument: StatContestant::class)]
    private Collection $contestants;

...

    /**
     * Teams
     *
     * @var Collection<array-key, StatMember>
     */
    #[Groups(['game:list'])]
    #[Assert\NotNull]
    #[ODM\EmbedMany(targetDocument: StatMember::class)]
    private Collection $members;

Additional context

No response

p-golovin avatar Apr 18 '24 21:04 p-golovin

Looks like a bug introduced with the implementation of PHPStan https://github.com/nelmio/NelmioApiDocBundle/pull/2249

DjordyKoert avatar Apr 19 '24 08:04 DjordyKoert