diff --git a/src/Config/Filters.php b/src/Config/Filters.php index 5d7cc3d1..772e45bb 100644 --- a/src/Config/Filters.php +++ b/src/Config/Filters.php @@ -160,9 +160,11 @@ private function handleTags(string|int|TaggedValue $value): array $operator = '='; if ($value instanceof TaggedValue) { - if ($value->getTag() === 'NOT') { - $operator = '!='; - } + match ($value->getTag()) { + 'NOT' => $operator = '!=', + 'IN' => $operator = 'contains', + default => $operator, + }; $value = (string) $value->getValue(); } diff --git a/src/Preparator/Config/Error400BadFormatsPreparatorConfig.php b/src/Preparator/Config/Error400BadFormatsPreparatorConfig.php deleted file mode 100644 index 18e17d0d..00000000 --- a/src/Preparator/Config/Error400BadFormatsPreparatorConfig.php +++ /dev/null @@ -1,9 +0,0 @@ -config->excludeOpenApiEndpoints - && isset($operation->getExtensions()['x-usecase'])) { - return []; - } $requiredParams = $operation->getParameters(true); return array_merge( diff --git a/src/Util/Traits/FilterableTrait.php b/src/Util/Traits/FilterableTrait.php index 6e229c47..7ef8b7c0 100644 --- a/src/Util/Traits/FilterableTrait.php +++ b/src/Util/Traits/FilterableTrait.php @@ -9,6 +9,7 @@ trait FilterableTrait public function has(string $prop, $value, string $operator = '='): bool { $self = collect([$this]); + if (str_contains($prop, '*')) { $operator = 'contains'; } diff --git a/tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php b/tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php index b762e1f8..a74d2b5c 100644 --- a/tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php +++ b/tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php @@ -22,7 +22,7 @@ final class Error400MissingRequiredFieldsPreparatorTest extends \PHPUnit\Framewo * @dataProvider getData * * @param array> $config - * @param TestCase[] $expected + * @param TestCase[] $expected */ public function test(Api $api, array $expected, array $config = []): void { @@ -165,48 +165,5 @@ public function getData(): iterable ), ], ]; - - yield 'openapi endpoint is ignored' => [ - Api::create() - ->addOperation( - Operation::create( - 'test', - '/test', - 'POST' - ) - ->addRequestBody( - (new Body( - new Schema([ - 'type' => 'object', - 'properties' => [ - 'foo' => [ - 'type' => 'string', - ], - 'bar' => [ - 'type' => 'string', - ], - ], - 'required' => ['foo'], - ]), - 'application/json' - )) - ) - ->addExample( - OperationExample::create('foo') - ->setBodyContent([ - 'foo' => 'foo_body1', - 'bar' => 'bar_body1', - ]) - ->setQueryParameter('foo_query', 'foo1') - )->setExtensions([ - 'x-usecase' => 'UseCaseName', - ]) - ), - [ - ], - [ - 'excludeOpenApiEndpoints' => true, - ], - ]; } }