diff --git a/.idea/php.xml b/.idea/php.xml
index 97cddef..631724e 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -214,6 +214,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/devenv.lock b/devenv.lock
index 8610224..aca2b74 100644
--- a/devenv.lock
+++ b/devenv.lock
@@ -3,11 +3,10 @@
"devenv": {
"locked": {
"dir": "src/modules",
- "lastModified": 1708326833,
- "narHash": "sha256-cihQPArrJhDU1jqqKDeyI91ZK62lUlGXYNncz2k9mjk=",
+ "lastModified": 1736426010,
"owner": "cachix",
"repo": "devenv",
- "rev": "bc4602a41c197edd5838c8a97da2ed0c1fc75d0e",
+ "rev": "1c384bc4be3ee571511fbbc6fdc94fe47d60f6cf",
"type": "github"
},
"original": {
@@ -20,11 +19,10 @@
"flake-compat": {
"flake": false,
"locked": {
- "lastModified": 1696426674,
- "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+ "lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
- "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
@@ -33,37 +31,39 @@
"type": "github"
}
},
- "flake-utils": {
+ "git-hooks": {
"inputs": {
- "systems": "systems"
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
},
"locked": {
- "lastModified": 1701680307,
- "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
+ "lastModified": 1735882644,
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "a5a961387e75ae44cc20f0a57ae463da5e959656",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
- "pre-commit-hooks",
+ "git-hooks",
"nixpkgs"
]
},
"locked": {
- "lastModified": 1703887061,
- "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
+ "lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
- "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
@@ -74,11 +74,10 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1708247094,
- "narHash": "sha256-H2VS7VwesetGDtIaaz4AMsRkPoSLEVzL/Ika8gnbUnE=",
+ "lastModified": 1736848588,
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "045b51a3ae66f673ed44b5bbd1f4a341d96703bf",
+ "rev": "357cd3dfdb8993af11268d755d53357720675e66",
"type": "github"
},
"original": {
@@ -88,66 +87,14 @@
"type": "github"
}
},
- "nixpkgs-stable": {
- "locked": {
- "lastModified": 1704874635,
- "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
- "owner": "NixOS",
- "repo": "nixpkgs",
- "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
- "type": "github"
- },
- "original": {
- "owner": "NixOS",
- "ref": "nixos-23.11",
- "repo": "nixpkgs",
- "type": "github"
- }
- },
- "pre-commit-hooks": {
- "inputs": {
- "flake-compat": "flake-compat",
- "flake-utils": "flake-utils",
- "gitignore": "gitignore",
- "nixpkgs": [
- "nixpkgs"
- ],
- "nixpkgs-stable": "nixpkgs-stable"
- },
- "locked": {
- "lastModified": 1708018599,
- "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=",
- "owner": "cachix",
- "repo": "pre-commit-hooks.nix",
- "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431",
- "type": "github"
- },
- "original": {
- "owner": "cachix",
- "repo": "pre-commit-hooks.nix",
- "type": "github"
- }
- },
"root": {
"inputs": {
"devenv": "devenv",
+ "git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
- "pre-commit-hooks": "pre-commit-hooks"
- }
- },
- "systems": {
- "locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
- "type": "github"
- },
- "original": {
- "owner": "nix-systems",
- "repo": "default",
- "type": "github"
+ "pre-commit-hooks": [
+ "git-hooks"
+ ]
}
}
},
diff --git a/src/Definition/Loader/OpenApiDefinitionLoader.php b/src/Definition/Loader/OpenApiDefinitionLoader.php
index fdc9843..581b00e 100644
--- a/src/Definition/Loader/OpenApiDefinitionLoader.php
+++ b/src/Definition/Loader/OpenApiDefinitionLoader.php
@@ -593,6 +593,10 @@ private function extractDeepExamples(Schema $schema, bool $optional = false, str
if (isset($schema->type)) {
if ($schema->type === 'array' && $schema->items instanceof Schema) {
+ if ($schema->example !== null) {
+ return $schema->example;
+ }
+
return [
$this->extractDeepExamples($schema->items, false, $path),
];
diff --git a/src/Preparator/Config/PreparatorConfig.php b/src/Preparator/Config/PreparatorConfig.php
index 0b5786d..57d1fcc 100644
--- a/src/Preparator/Config/PreparatorConfig.php
+++ b/src/Preparator/Config/PreparatorConfig.php
@@ -15,6 +15,11 @@ class PreparatorConfig
public ResponseConfig $response;
+ /**
+ * @var array
+ */
+ public array $headers = [];
+
public function __construct()
{
$this->response = new ResponseConfig();
diff --git a/src/Preparator/TestCasesPreparator.php b/src/Preparator/TestCasesPreparator.php
index a437643..097c070 100644
--- a/src/Preparator/TestCasesPreparator.php
+++ b/src/Preparator/TestCasesPreparator.php
@@ -51,6 +51,8 @@ final public function buildTestCase(
$example->setAuthenticationHeaders($this->tokens);
}
+ $example->setHeaders($this->config->headers);
+
return new TestCase(
static::getName()
. ' - '
diff --git a/src/Requester/HttpDumpRequester.php b/src/Requester/HttpDumpRequester.php
new file mode 100644
index 0000000..4cdb68c
--- /dev/null
+++ b/src/Requester/HttpDumpRequester.php
@@ -0,0 +1,60 @@
+requestToHttp($request, $id);
+
+ echo "\n" . $httpDump . "\n";
+
+ $response = new Response($request->getMethod() === 'POST' ? 201 : 200);
+ $this->responses[$id] = $response;
+ }
+
+ public function getResponse(string $id): ResponseInterface
+ {
+ return $this->responses[$id];
+ }
+
+ public static function getName(): string
+ {
+ return 'http-dump';
+ }
+
+ private function requestToHttp(RequestInterface $request, string $requestName): string
+ {
+ $dump = "###\n";
+ $dump .= $request->getMethod() . ' ' . '{{url}}' . $request->getUri() . "\n";
+
+ foreach ($request->getHeaders() as $name => $values) {
+ foreach ($values as $value) {
+ $dump .= "{$name}: {$value}\n";
+ }
+ }
+
+ $body = (string) $request->getBody();
+ if (!empty($body)) {
+ if (Json::isJson($body)) {
+ $body = Json::prettify($body);
+ }
+ $dump .= "\n" . $body . "\n";
+ }
+
+ return $dump;
+ }
+}
diff --git a/src/Requester/Requester.php b/src/Requester/Requester.php
index 31b5f63..1de165a 100644
--- a/src/Requester/Requester.php
+++ b/src/Requester/Requester.php
@@ -26,8 +26,6 @@ abstract public function request(RequestInterface $request, string $id): void;
abstract public function getResponse(string $id): ResponseInterface;
- abstract public function setBaseUri(string $baseUri): void;
-
protected function fillRequestVars(RequestInterface $request): void
{
foreach ($request->getHeaders() as $name => $header) {
diff --git a/src/Test/TestCase.php b/src/Test/TestCase.php
index 92c26c9..1eb9e8f 100644
--- a/src/Test/TestCase.php
+++ b/src/Test/TestCase.php
@@ -91,7 +91,7 @@ public function __construct(
$this->id = Random::id('testcase_');
$this->excludedFields = array_unique([...$this->excludedFields, ...$excludedFields]);
$nameParts = explode(' - ', $name);
- $this->preparator = $nameParts[0] ?? null;
+ $this->preparator = $nameParts[0] ?? '';
$this->operation = $nameParts[1] ?? null;
$this->request = $operationExample->getPsrRequest();
$this->schemaValidation = $schemaValidation;