Skip to content

fix(metadata): infer schema for Link URI variables from linked property - #8668

Closed
bram123 wants to merge 35 commits into
api-platform:mainfrom
bram123:link-uri-variable-schema-inference
Closed

bram123 wants to merge 35 commits into
api-platform:mainfrom
bram123:link-uri-variable-schema-inference

Conversation

@bram123

@bram123 bram123 commented Oct 11, 2026

Copy link
Copy Markdown
Q A
Branch? 5.0
Tickets Closes #8646
License MIT
Doc PR

When defining URI variables using Link without an explicit schema, OpenAPI generated path parameters defaulted to generic string types and lost format information (such as UUID/ULID or integer types) from the target property metadata.

This PR infers primitive schema type and format in LinkFactory from the linked property when none is explicitly configured on the Link.

Functional Test

tests/Functional/OpenApiLinkSchemaTest.php

public function testLinkSchemaIsInferredFromLinkedProperty(): void
{
    $response = self::createClient()->request('GET', '/docs', [
        'headers' => ['Accept' => 'application/vnd.openapi+json'],
    ]);
    $this->assertResponseIsSuccessful();

    $json = $response->toArray();
    $parameters = $json['paths']['/link_schema_parents/{parentId}/children/{id}']['get']['parameters'];

    $parentParam = $parameters[0];
    $this->assertSame('path', $parentParam['in']);
    $this->assertTrue($parentParam['required']);
    $this->assertSame(['type' => 'string', 'format' => 'uuid'], $parentParam['schema']);

    $idParam = $parameters[1];
    $this->assertSame('path', $idParam['in']);
    $this->assertTrue($idParam['required']);
    $this->assertSame(['type' => 'integer'], $idParam['schema']);
}

soyuka and others added 19 commits October 2, 2026 14:22
…pi-platform#8613)

The Client class check added in api-platform#8574 ran first and autoloaded Client,
which uses HttpClientTrait. Without symfony/http-client that is a fatal
error, and the trait check that used to cover it was never reached.

Fixes api-platform#8612

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ionNormalizer (api-platform#7890)

Co-authored-by: soyuka <soyuka@users.noreply.github.com>
@soyuka

soyuka commented Oct 12, 2026

Copy link
Copy Markdown
Member

Thanks for the PR this looks like a new feature, I need to check what the consequences are on the openapi / hydra specs. Can you target main ?

@bram123

bram123 commented Oct 12, 2026

Copy link
Copy Markdown
Author

Thanks for the PR this looks like a new feature, I need to check what the consequences are on the openapi / hydra specs. Can you target main ?

I figured it was a bugfix, as Im not adding a new functionality to the framework, and am changing the incorrect parameter type in the generated spec to the correct type.

But I can ofcourse target main if preferred 👍

@bram123
bram123 changed the base branch from 5.0 to main October 12, 2026 17:54
@bram123 bram123 closed this Oct 12, 2026
@bram123
bram123 deleted the link-uri-variable-schema-inference branch October 12, 2026 18:04
@bram123

bram123 commented Oct 12, 2026 •

Copy link
Copy Markdown
Author

Thanks for the PR this looks like a new feature, I need to check what the consequences are on the openapi / hydra specs. Can you target main ?

I figured it was a bugfix, as Im not adding a new functionality to the framework, and am changing the incorrect parameter type in the generated spec to the correct type.

But I can ofcourse target main if preferred 👍

The correct answer is :no I can't ...
#8677 is the PR targeting main, I can't git/phpstorm ...

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.

[Metadata] Incorrect api schema for path variable

10 participants