Skip to content

Avoid calling getSerializableData() #98

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

SOHELAHMED7
Copy link
Member

@SOHELAHMED7 SOHELAHMED7 commented Mar 10, 2025

Fixes #81

This PR requires cebe/php-openapi#228 to be merged first.

TODO
  • Once a new version of cebe/php-openapi is tagged, update its version in composer.json file

@SOHELAHMED7 SOHELAHMED7 requested a review from cebe March 10, 2025 09:29
@SOHELAHMED7 SOHELAHMED7 self-assigned this Mar 10, 2025
@SOHELAHMED7 SOHELAHMED7 linked an issue Mar 10, 2025 that may be closed by this pull request
@cebe
Copy link
Member

cebe commented Mar 12, 2025

changing the behavior of required and nullable is a major breaking change, if we want to do that we should do it before 2.0 stable release. Also need to check how that affects our spec in layer5.

@cebe cebe added this to the 2.0.0 milestone Mar 12, 2025
@SOHELAHMED7
Copy link
Member Author

Also need to check how that affects our spec in layer5

I will check this PR in L5 to see how much spec there requires change

… github.com:php-openapi/yii2-openapi into 81-avoid-calling-getserializabledata
@SOHELAHMED7
Copy link
Member Author

SOHELAHMED7 commented Mar 12, 2025

As I mentioned in #81 (comment), getSerializableData() is used for 2 things:

  1. resolving properties
  2. faker generation

While fixing 2nd, I found that 1st might be fixed without introducing breaking change if a change is introduced upstream library cebe/php-openapi. This change is required for 2nd.

Change is to introduce a public property in cebe\openapi\SpecBaseObject and cebe\openapi\spec\Reference class which will hold raw spec data. Example:

namespace cebe\openapi;

abstract class SpecBaseObject implements SpecObjectInterface, DocumentContextInterface
{
+   public $rawSpec;
    public function __construct(array $data)
    {
+       $this->rawSpec = $data;

Though I still recommend to introduce breaking change and make this library more and more spec compliant.

Example usage: 9538035

Implementation in upstream lib: cebe/php-openapi#228

… github.com:php-openapi/yii2-openapi into 81-avoid-calling-getserializabledata
@SOHELAHMED7 SOHELAHMED7 marked this pull request as ready for review May 13, 2025 11:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid calling getSerializableData()
2 participants