array<string, mixed> only allows string values in the generated schema
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- api, backend-api-design
Research direction
Start in SchemaPropertyMetadataFactory, where the issue identifies TypeIdentifier::MIXED as mapping to string; inspect nearby type handling and related schema tests. Check how the generated schema represents mixed, then update or add a focused test showing that numeric values such as 0 are accepted. Done when generated schemas allow any value for mixed properties.
Written by the indexing model from the issue text.
Description
The problem
API Platform treats mixed as string when it generates the OpenAPI schema. A property that can hold any value ends up as "strings only".
Example
/** @var array<string, mixed> */
public array $metadata = [];
The data is {"chunk_number": 0}. The number 0 is valid for mixed.
The generated schema says:
"metadata": { "type": "object", "additionalProperties": { "type": ["string", "null"] } }
That only allows strings and null. A client that validates the data against the schema reports it as invalid.
What I expected
mixed means "any value", so the schema should allow any value.
Where it comes from
SchemaPropertyMetadataFactory contains TypeIdentifier::MIXED => ['type' => 'string']. It is also on main.
Version: api-platform/core 4.4.2
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 987
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 76
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
Doctrine\Orm\OrderExtension fails on SortDirectionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
api-platform/core#8660 ·
Maintainers usually reply within 1 day
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
api-platform/core#8650 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
api-platform/core#8649 ·
Maintainers usually reply within 1 day
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
api-platform/core#8648 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
api-platform/core#8647 ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
WordPress/hosting-handbook#506 ·
Maintainers usually reply within 2 days
-
Installing a plugin with composer_packages installs dev dependencies and breaks the autoloader (Error 500)Possibly taken @Boy132 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
nginx: static-file locations drop the security headers, and the dotfile deny is matched after themOpenbug Low Security
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
backdrop-contrib/commerce#60 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100