Closed yapro closed 4 years ago
AnalyticalReportResource has no properties?
@soyuka yes, like you see, all properties in AnalyticalReportInput and AnalyticalReportOutput objects.
Nope it's not working like this.
@soyuka so the documentation is outdated?
Having an input and an output never creates properties on a class.
@soyuka like you see, I don't wont to create the AnalyticalReportResource, but api-platform doesn't work without a third class (resource class), am I right?
Indeed, you need a resource class. You can also use symfony to declare a custom route without using our concepts.
Actually, to me this is a bug. Currently the PropertyInfoPropertyNameCollectionFactory
throws an exception when it can't determine any properties. However, that should be considered perfectly normal, if a resource class does not have properties, or does not have properties which can be found by the PropertyInfo
component, as other decorator factories can still fill that in.
I've come across this while working on other issues, and I'm not sure what's the rationale behind this.
/cc @dunglas if you remember why...
I am using a resource class and using some value objects which only contain private properties and are not resources.
Uncaught PHP Exception ApiPlatform\Core\Exception\RuntimeException: "There is no PropertyInfo extractor supporting the class "App\Domain\Value\Tagdefinition\TagdefinitionUuid"." at /app/vendor/api-platform/core/src/Bridge/Symfony/PropertyInfo/Metadata/Property/PropertyInfoPropertyNameCollectionFactory.php line 46
I can confirm that adding a dummy public $foo;
property to the object fixes the error.
As PropertyNameCollection
can handle an empty array, why not pass this instead of raising an exception?
https://github.com/api-platform/core/blob/f8ccee08710d442f0333530e96b835620947aa82/src/Metadata/Property/PropertyNameCollection.php#L31-L34
in
I am not able to say sth. about the side effects or why this code behaves like this, but I am open to provide a PR if you agree @dunglas @teohhanhui
Cheers
EDIT It was introduces 4 years ago by @dunglas in Fix some Scrutinizer issues
cc @localheinz
TBH I don't remember the rationale (if any...). If tests pass, it should be safe to change this behavior!
Thanks for your feedback!
API Platform version(s) affected: v2.5.4
Description
I try to implementing a custom operation (without specifying an ID). My situation:
I have Post request.
I try to solve my problem as it is written in the https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
But, I have problem:
How to reproduce
https://github.com/yapro/api-platform-test/commit/bc70662c4f06b7769b781114d1d09031e47bb18f