Issue with docs generation for array of strings
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
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 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 ?
👀 will reverify this asap with the latest version of APIP