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

[Proposal] Update Swagger's definition keys (more verbose) #1207

Merged
merged 1 commit into from Jun 29, 2017

Conversation

meyerbaptiste
Copy link
Member

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

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:

capture d ecran 2017-06-27 a 14 57 33

After:

capture d ecran 2017-06-27 a 14 51 53

WDYT?

@Simperfit
Copy link
Contributor

IIRC they should be unique

@meyerbaptiste
Copy link
Member Author

They are!

@Simperfit
Copy link
Contributor

LGTM but I want to have @dunglas's confirmation on this.

Could you rebase thought ?

@Simperfit Simperfit requested a review from dunglas June 27, 2017 15:12
} else {
$definitionKey = $resourceMetadata->getShortName();
}
$definitionKey = $this->getDefinitionKey($resourceMetadata->getShortName(), (array) ($serializerContext['groups'] ?? null));
Copy link
Member

Choose a reason for hiding this comment

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

$serializerContext['groups'] ?? []?

Copy link
Member

@dunglas dunglas left a 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
Copy link
Member

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);
Copy link
Member

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).

@meyerbaptiste
Copy link
Member Author

Changes are done.

@soyuka
Copy link
Member

soyuka commented Jun 29, 2017

WTF the coverage, men this drives me nuts. We may wanna think about changing the coverage service...

https://twitter.com/s0yuka/status/880356057956143106

@dunglas dunglas merged commit ac627cd into api-platform:master Jun 29, 2017
@dunglas
Copy link
Member

dunglas commented Jun 29, 2017

Thank you @meyerbaptiste!

@meyerbaptiste meyerbaptiste deleted the update_definition_key branch June 29, 2017 13:02
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
…tion_key

[Proposal] Update Swagger's definition keys (more verbose)
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.

None yet

4 participants