Skip to content

Find suitable value for oneOf property in parameters. Fix #166 - #168

Open
sloory wants to merge 5 commits into
thephpleague:masterfrom
sloory:fix-oneof-in-parameters
Open

Find suitable value for oneOf property in parameters. Fix #166#168
sloory wants to merge 5 commits into
thephpleague:masterfrom
sloory:fix-oneof-in-parameters

Conversation

@sloory

@sloory sloory commented May 13, 2022

Copy link
Copy Markdown

No description provided.

@sloory sloory changed the title Find suitable value for oneOf property in parameters. Fix #166 Find suitable value for oneOf property in parameters. May 13, 2022
@sloory sloory changed the title Find suitable value for oneOf property in parameters. Find suitable value for oneOf property in parameters. Fix #166 May 13, 2022
@sloory

sloory commented May 13, 2022

Copy link
Copy Markdown
Author

this PR fix #166

@scaytrase scaytrase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some fixing for negative cases

foreach ($value as $key => &$val) {
$childSchema = $this->getChildSchema($schema, (string) $key);

if (isset($childSchema->oneOf)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like in this case we should immediately stop validation if we have filled oneOf and none of the schemas matched in findSuitableOneOf.


try {
$validator->validate($psrRequest);
$this->assertTrue(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not proper way how to deal with exceptions and zero assertions. proper way would be (without any try..catch)

$validator->validate($psrRequest);
$this->addToAssrtionsCount(1);

any exception thrown here should break the test and if validate throws one assertTrue(true) is not called anyway

*/
final class Issue166Test extends BaseValidatorTest
{
public function testIssue166(): void

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some negative cases required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In case of specified oneOf property in parameters library does not find suitable

2 participants