Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
Update Property.php
Browse files Browse the repository at this point in the history
Support for multiple types on a field
  • Loading branch information
newLoki authored Jun 8, 2017
1 parent 562b589 commit d5659b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Knp/JsonSchemaBundle/Model/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ public function jsonSerialize()
if (!empty($this->type)) {
if (count($this->type) === 1) {
$serialized['type'] = $this->type[0];
} elseif (count($this->type) > 1) {
$serialized['oneOf'] = [];

foreach ($this->type as $type) {
$serialized['oneOf'][] = ['type' => $type];
}
} else {
$serialized['type'] = $this->type;
}
Expand Down

0 comments on commit d5659b1

Please sign in to comment.