-
-
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
Implement subresource metadata and annotation #1206
Conversation
@@ -33,7 +34,7 @@ class Container | |||
private $id; | |||
|
|||
/** | |||
* @ApiProperty(subresource=true) | |||
* @ApiProperty(subresource=@ApiSubresource()) |
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.
Should it be a PROPERTY
annotation? I don't think we need it, and there is no value in adding metadata factories for subresources IMO. Lmk.
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 agree, @ApiSubresource()
directly on the property is easier to type, to read and to understand.
src/Annotation/ApiSubresource.php
Outdated
* @author Antoine Bluchet <soyuka@gmail.com> | ||
* | ||
* @Annotation | ||
* @Target({"ANNOTATION"}) |
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.
Should be @Target({"METHOD", "PROPERTY"})
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.
Nevermind, my bad.
I suggest we take this opportunity to make it: /**
* @ApiSubresource(operations=true)
*/
protected $children; (open to better name) |
What does |
|
On second thought, we should add |
Okay but I suggest we expose operations without having a |
Okay, maybe we need to have a clear definition of what we call a subresource (for our purposes):
|
9568252
to
4f03571
Compare
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.
Ok for me when Travis will be green (see comment).
|
||
$collectionType = new Type(Type::BUILTIN_TYPE_OBJECT, | ||
false, | ||
ArrayCollection::class, |
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.
Missing use
statement (it should made Travis happy btw).
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.
last minute test \o/ fixed thx.
d5bc50b
to
a955dac
Compare
* | ||
* @return SubresourceMetadata|null | ||
*/ | ||
public function getSubresource(): SubresourceMetadata |
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.
You have to remove the return type here.
a955dac
to
8a393ca
Compare
* | ||
* @author Antoine Bluchet <soyuka@gmail.com> | ||
*/ | ||
final class SubresourceMetadata |
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'm -1 for this. It duplicates information already available from the Type
via PropertyMetadata
.
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.
It does and in the end we'll have less function calls to retrieve the same information.
$isCollection = $propertyMetadata->getType()->isCollection();
$subresource = $isCollection ? $propertyMetadata->getType()->getCollectionValueType()->getClassName() : $propertyMetadata->getType()->getClassName();
This will also ease the maintenance to have a SubresourceMetadata class if we need to support subresource related cases in the future no?
Thanks @soyuka! |
Hi!! For example I have Objects that have many comments! and i would like recover the comments through the Object and paging the reponse!! |
Please open a new issue, and if it's a collection it should already be paginated. |
@soyuka It's already implemted! It was that i didnt see it in the subResource url api_doc. |
Implement subresource metadata and annotation
For now the @ApiSubresource only does the same thing as
@ApiProperty(subresource=true)
. It'll be better with metadata and an annotation class if we want to add features to it in the future.Related to #1188. ping @pierredup