-
-
Notifications
You must be signed in to change notification settings - Fork 897
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
[Proposal] Update Swagger's definition keys (more verbose) #1207
[Proposal] Update Swagger's definition keys (more verbose) #1207
Conversation
IIRC they should be unique |
They are! |
LGTM but I want to have @dunglas's confirmation on this. Could you rebase thought ? |
} else { | ||
$definitionKey = $resourceMetadata->getShortName(); | ||
} | ||
$definitionKey = $this->getDefinitionKey($resourceMetadata->getShortName(), (array) ($serializerContext['groups'] ?? null)); |
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.
$serializerContext['groups'] ?? []
?
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.
👍 for the idea!
* @param string $resourceShortName | ||
* @param array $groups | ||
* | ||
* @return string |
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.
Useless docblock, can be removed
*/ | ||
private function getDefinitionKey(string $resourceShortName, array $groups): string | ||
{ | ||
return !$groups ? $resourceShortName : $resourceShortName.'_groups_'.implode('_', $groups); |
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.
I suggest the following to avoid a useless negation: $groups ? sprintf('%s-%s', $resourceShortName, implode('_', $groups)) : $resourceShortName
I also suggest to replace the _groups_
part by a single dash (less verbose).
ccb7b0b
to
1176a45
Compare
1176a45
to
ec1a19d
Compare
Changes are done. |
WTF the coverage, men this drives me nuts. We may wanna think about changing the coverage service... |
Thank you @meyerbaptiste! |
…tion_key [Proposal] Update Swagger's definition keys (more verbose)
Since Swagger-UI 3.x, definitions are exposed in the ui. My proposal is to make them more verbose when an operation has defined roles. So instead of a md5 hash, I propose to use a slug.
Slug can be discussed and currently I use
_groups_<group x>_<group y>_<group ...>
.Before:
After:
WDYT?