Skip to content

Commit 06c3714

Browse files
committed
Support empty object
1 parent 0fee120 commit 06c3714

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Base/Body.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ protected function matchSchema($name, $schemaArray, $body)
414414
return true;
415415
}
416416

417+
// Match any object
418+
if (count($schemaArray) === 1 && isset($schemaArray['type']) && $schemaArray['type'] === 'object') {
419+
return true;
420+
}
421+
417422
throw new GenericSwaggerException("Not all cases are defined. Please open an issue about this. Schema: $name");
418423
}
419424

src/Base/Schema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use ByJG\ApiTools\Exception\GenericSwaggerException;
77
use ByJG\ApiTools\Exception\HttpMethodNotFoundException;
88
use ByJG\ApiTools\Exception\InvalidDefinitionException;
9+
use ByJG\ApiTools\Exception\InvalidRequestException;
910
use ByJG\ApiTools\Exception\NotMatchedException;
1011
use ByJG\ApiTools\Exception\PathNotFoundException;
1112
use ByJG\ApiTools\OpenApi\OpenApiSchema;
@@ -98,6 +99,9 @@ public function getPathDefinition($path, $method)
9899
$pathItemPattern = '~^' . preg_replace('~{(.*?)}~', '(?<\1>[^/]+)', $pathItem) . '$~';
99100

100101
$matches = [];
102+
if (empty($uri->getPath())) {
103+
throw new InvalidRequestException('The path is empty');
104+
}
101105
if (preg_match($pathItemPattern, $uri->getPath(), $matches)) {
102106
$pathDef = $this->jsonFile[self::SWAGGER_PATHS][$pathItem];
103107
if (!isset($pathDef[$method])) {

0 commit comments

Comments
 (0)