Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger Path Identifier to reflect the annotation of ApiProperty(identifier=true) #1367

Closed
wants to merge 2 commits into from
Closed

Swagger Path Identifier to reflect the annotation of ApiProperty(identifier=true) #1367

wants to merge 2 commits into from

Conversation

Bwen
Copy link

@Bwen Bwen commented Sep 12, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

$pathIdentifier = $propertyName;
$pathType = $property->getType()->getBuiltinType();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an issue on composite identifiers here. Indeed, a composite identifier would be written as a string (for example foo=1;bar=2). With this code, the identifier would only be bar./
About the id name, I think it's like this so that it's being used in the path from Swagger. I'm not sure how Swagger is identifying the url parameter like this.

You could maybe reuse the same code from a new method instead of repeating it.

…ed legacy @expectedDeprecation for test and removed silly @group annotation for test
private function getPathParameters(string $resourceClass)
{
$parameters = [];
$properties = $this->getClassIdentifiers($resourceClass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$identifiers instead of $properties?

];
}

if (empty($parameters)) {
Copy link
Member

@meyerbaptiste meyerbaptiste Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!$identifiers = $this->getClassIdentifiers($resourceClass)) {
    return [[
        'name' => 'id',
        'in' => 'path',
        'required' => true,
        'type' => 'string',
    ]];
}

$parameters = [];
foreach ($identifiers as $identifier => $property) {
    $parameters[] = [ ... ];
}

return $parameters; 


if (empty($parameters)) {
$parameters = [[
'name' => "id",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use simple quotes.

'name' => "id",
'in' => 'path',
'required' => true,
'type' => "string",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use simple quotes.

/**
*
* @group legacy
* @expectedDeprecation Passing an instance of ApiPlatform\Core\Api\UrlGeneratorInterface to ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer::__construct() is deprecated since version 2.1 and will be removed in 3.0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these annotations and fix the constructor instead.

* @group legacy
* @expectedDeprecation Passing an instance of ApiPlatform\Core\Api\UrlGeneratorInterface to ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer::__construct() is deprecated since version 2.1 and will be removed in 3.0.
*/
public function testNormalizeWithIdentifierName()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test with composite identifiers?

* @param string $resourceClass
* @return PropertyMetadata[]
*/
private function getClassIdentifiers(string $resourceClass)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Simperfit
Copy link
Contributor

Could you please finish this ?

@flug
Copy link
Contributor

flug commented Nov 14, 2019

@Bwen Up is this pull request still valid?

@gphilippe
Copy link

No idea... lost interest, sorry. 😢

I guess not?

@soyuka soyuka closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants