Skip to content

Commit f711070

Browse files
authored
Merge pull request #22 from membrane-php/use-devizzent-fork
Use devizzent/cebe-php-openapi
2 parents 869c84a + bff27d2 commit f711070

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require": {
1818
"php": "^8.1.0",
19-
"cebe/php-openapi": "^1.7"
19+
"devizzent/cebe-php-openapi": "^1.1.0"
2020
},
2121
"require-dev": {
2222
"phpunit/phpunit": "^10.5.36",

src/Exception/InvalidOpenAPI.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,16 @@ public static function invalidType(Identifier $identifier, string $type): self
301301
return new self($message);
302302
}
303303

304+
public static function typeArrayInWrongVersion(Identifier $identifier): self
305+
{
306+
$message = <<<TEXT
307+
$identifier
308+
Specifying type as an array is only valid for OpenAPI ^3.1
309+
TEXT;
310+
311+
return new self($message);
312+
}
313+
304314
public static function failedCebeValidation(string ...$errors): self
305315
{
306316
$message = sprintf("OpenAPI is invalid for the following reasons:\n\t- %s", implode("\n\t- ", $errors));

src/ValueObject/Partial/Schema.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
final class Schema
88
{
99
/**
10+
* @param array<string>|string|null $type
1011
* @param ?self[] $allOf
1112
* @param ?self[] $anyOf
1213
* @param ?self[] $oneOf
1314
*/
1415
public function __construct(
15-
public ?string $type = null,
16+
public array|string|null $type = null,
1617
public ?array $allOf = null,
1718
public ?array $anyOf = null,
1819
public ?array $oneOf = null,

src/ValueObject/Valid/V30/Schema.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ public function __construct(
9191
}
9292
}
9393

94-
private function validateType(Identifier $identifier, ?string $type): ?Type
94+
/** @param array<string>|string|null $type */
95+
private function validateType(Identifier $identifier, array|string|null $type): ?Type
9596
{
9697
if (is_null($type)) {
9798
return null;
9899
}
99100

101+
if (is_array($type)) {
102+
return throw InvalidOpenAPI::typeArrayInWrongVersion($this->getIdentifier());
103+
}
104+
100105
return Type::tryFromVersion(
101106
OpenAPIVersion::Version_3_0,
102107
$type

0 commit comments

Comments
 (0)