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

Improve Swagger's DocumentationNormalizer #740

Merged
merged 2 commits into from
Sep 9, 2016

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Sep 8, 2016

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

],
'404' => [
'description' => 'Resource not found',
$pathOperation['tags'] ?? $pathOperation['tags'] = [$resourceShortName];
Copy link
Contributor

Choose a reason for hiding this comment

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

What's going on here? 😆

Copy link
Member Author

@dunglas dunglas Sep 8, 2016

Choose a reason for hiding this comment

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

Git(Hub) fails to create a good diff, but the underlying code looks ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, shouldn't it be:

$pathOperation['tags'] = $pathOperation['tags'] ?? [$resourceShortName];

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? It makes an useless assignation.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO that's a bad coding style. Too cryptic and most likely doesn't even have any practical benefit.

It's short-circuit on steroids... lol

Copy link
Member Author

Choose a reason for hiding this comment

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

I find it clearer but it's probably a personal taste :)

Copy link
Member

Choose a reason for hiding this comment

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

It's called job-safety not short-circuit on steroids 😸

@@ -129,8 +133,8 @@ private function parseResource(ResourceMetadata $resourceMetadata, string $resou
private function getGroupsForItemAndCollectionOperation(ResourceMetadata $resourceMetadata, string $operationName) : array
{
$operation = [
'denormalization_context' => array_merge($resourceMetadata->getItemOperationAttribute($operationName, 'denormalization_context', []), $resourceMetadata->getCollectionOperationAttribute($operationName, 'denormalization_context', [])),
'normalization_context' => array_merge($resourceMetadata->getItemOperationAttribute($operationName, 'normalization_context', []), $resourceMetadata->getCollectionOperationAttribute($operationName, 'normalization_context', [])),
'denormalization_context' => $resourceMetadata->getItemOperationAttribute($operationName, 'denormalization_context', []) + $resourceMetadata->getCollectionOperationAttribute($operationName, 'denormalization_context', []),
Copy link
Contributor

@teohhanhui teohhanhui Sep 8, 2016

Choose a reason for hiding this comment

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

Why is there union of item + collection operation attributes going on? Only one of them can be applicable at a time.

Even if the intention is to only get one of them, what about collection and item operations with the same name? Too risky...

Copy link
Member Author

@dunglas dunglas Sep 9, 2016

Choose a reason for hiding this comment

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

I 100% agree, this must be investigated. But this PR doesn't change the behavior, it's just a style fix. I propose to refactor this method in another PR. WDYT?

@dunglas dunglas merged commit 1a201de into api-platform:master Sep 9, 2016
@dunglas dunglas deleted the scrut branch September 9, 2016 11:38
magarzon pushed a commit to magarzon/core that referenced this pull request Feb 12, 2017
Improve Swagger's DocumentationNormalizer
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

3 participants