-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Properties in traits loaded in parent class are not generated #499
Comments
For additional informatie, it does not matter wether the parent class is |
This is an issue with swagger-php. allOf:
-
$ref: '#/components/schemas/Model'
``
Looks like the merge code does not lookup properties recursively through used traits in the (not schema) parent class.
Looks like there is also a bug involved because even if you annotate both `HasId` and `Model` with `/** @OA\Schema() */` the `Model` class is missing a `allOf` ref to `HasId`. |
Thanks for the clarification and opening an issue at the source repo! Let's see what they're suggesting or coming up with related to a fix. |
@rickgoemans There is a PR ready that addresses your issue: zircote/swagger-php#1331 Would you be able to try this and let me know if this fixes things for you? It sure does fix your reproducer :) |
It is fixed, thanks for the update and the fix! |
I just noticed that if you use a trait in both the parent (in my example the |
Since the title of this issue does not fully cover the new situation, should I create a new issue? My new setup would include another trait called Here's the trait: <?php
namespace ...
use Carbon\Carbon;
use OpenApi\Annotations as OA;
trait HasTimestamps
{
/**
* @OA\Property(
* format="date-time",
* type="string",
* readOnly=true,
* )
*/
public Carbon $created_at;
/**
* @OA\Property(
* format="date-time",
* type="string",
* readOnly=true,
* )
*/
public Carbon $updated_at;
} |
Not a new issue, but since this is purely swagger-php related we should move this over to zircote/swagger-php#1325 and close this one. |
composer show | grep l5-swagger
)php -v
): 8.1.10Description:
I have a small setup for models that prevent me from writing duplicate properties, but when I add properties via a trait to the parent (abstract) model class, they are not generated in the children models.
Steps To Reproduce:
Make the following 3 files (of course correct the namespace to your situation);
Here's the result of the JSON file:
Here's the result of Swagger UI:
If you then include the
HasId
trait within theAddress
model, it will be shown correctly.Of course I can move the
id
property to theModel
class, but the general thought is that I have some properties that cannot be placed within just one file.Anybody else experiencing similar issues and/or maybe know a good solution?
I can make a very complex class extending structure but that is not a realistic solution.
The text was updated successfully, but these errors were encountered: