Skip to content

array<string, mixed> only allows string values in the generated schema #8665

Closed

Description

@germanbisurgi

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

Activity

  1. added a commit that references this issue on Oct 12, 2026
    a71b683
  2. soyuka commented on Oct 13, 2026

    @soyuka
    Member

    fixed by #8670, mixed now emits an empty schema so any value is allowed, it'll ship with the next 4.4 patch. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions