core icon indicating copy to clipboard operation
core copied to clipboard

Issue with docs generation for array of strings

Open rvanlaak opened this issue 2 months ago • 2 comments

API Platform version(s) affected: 4.2.2 (after having updated from 4.1.23)

Description

The JSON LD schema of a resource's simple output DTO seems to now consider an array of strings as null[] where it was string[] on APIP 4.1.23

Image

How to reproduce

We use openapi-typescript to transform API Platform's documentation to types:

npx openapi-typescript "https://${SERVER_NAME}/docs.jsonopenapi" -o ./pwa/types/api-schema.d.ts

Possible Solution

Additional Context

The introduction of the HydraItemsBase of https://github.com/api-platform/core/issues/7426 through https://github.com/api-platform/core/pull/7444 is great. Could it have affected anything else?

DTO Shape:

<?php

namespace App\Domain\Shared\Specification;

use Symfony\Component\Serializer\Attribute\Groups;

#[Groups('me:read')]
final readonly class SpecificationResult
{
    private function __construct(
        public bool $passed,

        /**
         * @var list<non-empty-string>
         */
        public array $messages = [],
    ) {
    }
}

rvanlaak avatar Oct 18 '25 13:10 rvanlaak

@rvanlaak The JSON LD schema seems correct

      "SpecificationResult": {
        "type": "object",
        "properties": {
          "passed": {
            "readOnly": true,
            "type": "boolean"
          },
          "messages": {
            "readOnly": true,
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SpecificationResult.jsonld": {
        "type": "object",
        "properties": {
          "passed": {
            "readOnly": true,
            "type": "boolean"
          },
          "messages": {
            "readOnly": true,
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },

Is the problem still present ?

aaa2000 avatar Nov 26 '25 17:11 aaa2000

👀 will reverify this asap with the latest version of APIP

rvanlaak avatar Nov 27 '25 11:11 rvanlaak