-
-
Notifications
You must be signed in to change notification settings - Fork 848
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,11 @@ private function parseResource(ResourceMetadata $resourceMetadata, string $resou | |
} | ||
|
||
if (isset($attributes['denormalization_context']['groups'])) { | ||
$options['serializer_groups'] = isset($options['serializer_groups']) ? array_merge($options['serializer_groups'], $attributes['denormalization_context']['groups']) : $options['serializer_groups']; | ||
if (isset($options['serializer_groups'])) { | ||
$options['serializer_groups'] += $attributes['denormalization_context']['groups']; | ||
} else { | ||
$options['serializer_groups'] = $attributes['denormalization_context']['groups']; | ||
} | ||
} | ||
|
||
return $this->getPropertyMetadata($resourceMetadata, $resourceClass, $io, $visited, $options); | ||
|
@@ -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', []), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
'normalization_context' => $resourceMetadata->getItemOperationAttribute($operationName, 'normalization_context', []) + $resourceMetadata->getCollectionOperationAttribute($operationName, 'normalization_context', []), | ||
]; | ||
|
||
$options = [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the logic related to this whole function needs to be reviewed. I gave it a quick look and things look very fishy here.