Skip to content

Conversation

Cafeine42
Copy link

@Cafeine42 Cafeine42 commented Sep 23, 2025

Q A
Branch? 4.2
Tickets #7400
License MIT
Doc PR
image

Fix invalid anyOf usage in schema generation

The schema currently defines anyOf as an object instead of an array, which is invalid. Spectral linting (docker run --rm -it -v $(pwd):/tmp stoplight/spectral:6 lint /tmp/openapi.yaml) reports:

"anyOf property must be array."

This PR wraps $schemas with array_values, ensuring anyOf receives an array. The same approach is already used in other parts of the code.

@Cafeine42 Cafeine42 force-pushed the fix-openapi-anyof-object branch 2 times, most recently from 3296f8c to 97d0442 Compare September 23, 2025 06:02
@Cafeine42 Cafeine42 force-pushed the fix-openapi-anyof-object branch from 97d0442 to 10e8466 Compare September 23, 2025 06:40
@Cafeine42 Cafeine42 changed the base branch from main to 4.2 September 23, 2025 06:41
@soyuka
Copy link
Member

soyuka commented Sep 25, 2025

Oh wow thanks for the fix! Could provie your Resource that leads to that? I'd like to add this to our test to ensure no regression (I can handle this).

@Cafeine42
Copy link
Author

@soyuka I got this error on this rather exhaustive field :

/**
* @var array<array-key, string|numeric|bool|string[]|null>
*/
#[Groups(groups: ['item:user:read', 'item:user:write'])]
#[ORM\Column(type: 'jsonb')]
private array $preferences = [];

@soyuka soyuka force-pushed the fix-openapi-anyof-object branch from 0685403 to 74f8e29 Compare September 26, 2025 12:46
@soyuka soyuka merged commit a5102d9 into api-platform:4.2 Sep 26, 2025
107 of 114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants