Don't Use ref in Discriminator mapping

Instead just include the schema ref directly per the documentation.
This commit is contained in:
Christopher Davis 2021-02-08 15:39:14 -06:00
parent ac7e29da21
commit 87004fc428
2 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ trait ApplyOpenApiDiscriminatorTrait
$model->getOptions()
));
$schema->oneOf[] = $oneOfSchema;
$schema->discriminator->mapping[$propertyValue] = clone $oneOfSchema;
$schema->discriminator->mapping[$propertyValue] = $oneOfSchema->ref;
}
}
}

View File

@ -41,12 +41,12 @@ class ApplyOpenApiDiscriminatorTraitTest extends TestCase
$this->assertArrayHasKey('one', $this->schema->discriminator->mapping);
$this->assertSame(
$this->modelRegistry->register($this->createModel('FirstType')),
$this->schema->discriminator->mapping['one']->ref
$this->schema->discriminator->mapping['one']
);
$this->assertArrayHasKey('two', $this->schema->discriminator->mapping);
$this->assertSame(
$this->modelRegistry->register($this->createModel('SecondType')),
$this->schema->discriminator->mapping['two']->ref
$this->schema->discriminator->mapping['two']
);
}