Skip to content

fix(metadata): incorrect property schema format for ip version=all - #8667

Open
bram123 wants to merge 3 commits into
api-platform:5.0from
bram123:ip_all_property_schema_format
Open

bram123 wants to merge 3 commits into
api-platform:5.0from
bram123:ip_all_property_schema_format

Conversation

@bram123

@bram123 bram123 commented Oct 11, 2026 •

Copy link
Copy Markdown
Q A
Branch? 5.0 for bug fixes
Tickets
License MIT
Doc PR

With the following ApiResource:

#[ApiResource(
    operations: [
        new GetCollection(provider: EntityStateProvider::class),
        new Get(provider: EntityStateProvider::class),
        new Post(processor: EntityStateProcessor::class)
    ],
)]
class Entity
{
    #[ApiProperty(identifier: true)]
    public ?int $id = null;

    #[Assert\Ip(version: 'all')]
    public string $ip = '';

    public function __construct(?int $id = null, string $ip = '')
    {
        $this->id = $id;
        $this->ip = $ip;
    }
}

This patch turns the "ip" property's schema from

format: ipv6
SwaggerUI image

into

oneOf:
  - format: ipv4
  - format: ipv6`
SwaggerUI image

To better document that both ip versions are possible as input/output.

I saw there is a dedicated PropertySchemaOneOfRestriction class, but imo this IP format does not fit in there so I opted to keep it in the PropertySchemaFormat class. Extra PropertySchemaOneOfRestriction test was added to assert combining the two.

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.

1 participant