Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Definition/Loader/OpenApiDefinitionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ private function getOperations(array $paths, array $securitySchemes, array $filt
->setTags($this->getTags($operation->tags))
->setSecurities($this->getSecurities($securitySchemes, $requirements))
->setExamples($this->getExamples($operation, $parameters))
->setExtensions($operation->getExtensions())
);
}
}
Expand Down
23 changes: 0 additions & 23 deletions src/Definition/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ final class Operation implements Filterable

private OperationExamples $examples;

/**
* @var array<string, mixed>
*/
private array $extensions;

public function __construct(
private readonly string $id,
private readonly string $path,
Expand Down Expand Up @@ -205,14 +200,6 @@ public function setResponses(Responses $responses): self
return $this;
}

/**
* @return array<string, mixed> $extensions
*/
public function getExtensions(): array
{
return $this->extensions;
}

public function getResponse(int $status): ?Response
{
return $this->responses->get($status);
Expand Down Expand Up @@ -290,16 +277,6 @@ public function setExamples(OperationExamples $examples): self
return $this;
}

/**
* @param array<string, mixed> $extensions
*/
public function setExtensions(array $extensions): self
{
$this->extensions = $extensions;

return $this;
}

/**
* @param array<int|string, string|int> $params
*
Expand Down
9 changes: 0 additions & 9 deletions src/Preparator/Config/Error400BadFormatsPreparatorConfig.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Preparator/Config/Error400BadTypesPreparatorConfig.php

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/Preparator/Config/Error400PreparatorConfig.php

This file was deleted.

10 changes: 1 addition & 9 deletions src/Preparator/Error400Preparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
use APITester\Definition\Example\ResponseExample;
use APITester\Definition\Operation;
use APITester\Definition\Parameter;
use APITester\Preparator\Config\Error400PreparatorConfig;
use APITester\Test\TestCase;

/**
* @property Error400PreparatorConfig $config
*/
abstract class Error400Preparator extends TestCasesPreparator
{
/**
Expand All @@ -27,7 +23,7 @@ protected function prepare(Operations $operations): iterable
{
/** @var iterable<array-key, TestCase> */
return $operations
->map(fn (Operation $operation) => $this->prepareTestCases($operation))
->map(fn (Operation $op) => $this->prepareTestCases($op))
->flatten()
;
}
Expand Down Expand Up @@ -122,10 +118,6 @@ protected function getStatusCode(): string
*/
private function prepareTestCases(Operation $operation): array
{
if ($this->config->excludeOpenApiEndpoints
&& isset($operation->getExtensions()['x-usecase'])) {
return [];
}
$requiredParams = $operation->getParameters(true);

return array_merge(
Expand Down
47 changes: 1 addition & 46 deletions tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ final class Error400MissingRequiredFieldsPreparatorTest extends \PHPUnit\Framewo
/**
* @dataProvider getData
*
* @param array<string, array<mixed>> $config
* @param TestCase[] $expected
*/
public function test(Api $api, array $expected, array $config = []): void
public function test(Api $api, array $expected): void
{
$preparator = new Error400MissingRequiredFieldsPreparator();
$preparator->configure($config);
Assert::objectsEqual(
$expected,
$preparator->doPrepare($api->getOperations()),
Expand Down Expand Up @@ -165,48 +163,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,
],
];
}
}
Loading