DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel
https://github.com/DarkaOnLine/L5-Swagger
MIT License
2.64k stars 394 forks source link

Override parent class's property in child #435

Closed degeta10 closed 1 year ago

degeta10 commented 2 years ago

Description:

I have two classes A and B. A is the base class and B is the extended class. Class A has a QA property with an example. Since class B extends class A, I want to override the QA property that exists in class A with a new example. Is this possible?

To me, it shows an error saying that there is multiple QA property present as I'm using class B as a ref in my documentation.

Steps To Reproduce:

Below is the code for class A:

class A {

    /**
     * @OA\Property(
     *     title="success",
     *     description="Success state",
     *     example="true"
     * )
     *
     * @var bool
     */
    public $success;

    /**
     * @OA\Property(
     *     title="message",
     *     description="A message from server",
     *     example="Success"
     * )
     *
     * @var string
     */
    public $message;
}

Below is the code for class B:

class B extends A {

    /**
     * @OA\Property(
     *     title="message",
     *     description="A message from server",
     *     example="Successfully created row"
     * )
     *
     * @var string
     */
    public $message;
}
DerManoMann commented 2 years ago

I think this is more a question for zircote/swagger-php and how inherited properties are merged. This could be a nice feature, although perhaps optional.. hmmm.