Repository navigation
Implement subresource metadata and annotation - #1206
Conversation
|
|
||
| /** | ||
| * @ApiProperty(subresource=true) | ||
| * @ApiProperty(subresource=@ApiSubresource()) |
There was a problem hiding this comment.
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.
I agree, @ApiSubresource() directly on the property is easier to type, to read and to understand.
| * @author Antoine Bluchet <soyuka@gmail.com> | ||
| * | ||
| * @Annotation | ||
| * @Target({"ANNOTATION"}) |
There was a problem hiding this comment.
Should be @Target({"METHOD", "PROPERTY"})
|
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
dunglas
left a comment
There was a problem hiding this comment.
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.
Missing use statement (it should made Travis happy btw).
There was a problem hiding this comment.
last minute test \o/ fixed thx.
d5bc50b to
a955dac
Compare
| * | ||
| * @return SubresourceMetadata|null | ||
| */ | ||
| public function getSubresource(): SubresourceMetadata |
There was a problem hiding this comment.
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.
I'm -1 for this. It duplicates information already available from the Type via PropertyMetadata.
There was a problem hiding this comment.
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