Skip to content
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

Implement JsonSerializable so OpenApi instance can be serialized using json_encode() #183

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
7 changes: 6 additions & 1 deletion src/SpecBaseObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
use cebe\openapi\json\JsonReference;
use cebe\openapi\spec\Reference;
use cebe\openapi\spec\Type;
use \JsonSerializable;

/**
* Base class for all spec objects.
*
* Implements property management and validation basics.
*
*/
abstract class SpecBaseObject implements SpecObjectInterface, DocumentContextInterface
abstract class SpecBaseObject implements SpecObjectInterface, DocumentContextInterface, JsonSerializable
{
private $_properties = [];
private $_errors = [];
Expand Down Expand Up @@ -525,4 +526,8 @@ public function getExtensions(): array
}
return $extensions;
}

public function jsonSerialize() {
return $this->getSerializableData();
}
}