From df8ddfcc9e9f34cd3af636ca600ae2af0f566575 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 28 Aug 2025 16:04:42 +0200 Subject: [PATCH] fix(OpenApiType): Remove boolean parameter quirk Signed-off-by: provokateurin --- src/OpenApiType.php | 12 ------------ tests/openapi-administration.json | 32 +++++++------------------------ tests/openapi-full.json | 32 +++++++------------------------ 3 files changed, 14 insertions(+), 62 deletions(-) diff --git a/src/OpenApiType.php b/src/OpenApiType.php index 398c55b8..4362673d 100644 --- a/src/OpenApiType.php +++ b/src/OpenApiType.php @@ -64,18 +64,6 @@ public function __construct( public function toArray(bool $isParameter = false): array|stdClass { if ($isParameter) { - if ($this->type === 'boolean') { - return (new OpenApiType( - context: $this->context, - type: 'integer', - nullable: $this->nullable, - hasDefaultValue: $this->hasDefaultValue, - defaultValue: $this->hasDefaultValue ? ($this->defaultValue === true ? 1 : 0) : (null), - description: $this->description, - enum: [0, 1], - ))->toArray($isParameter); - } - if ($this->type === 'object' || $this->ref !== null || $this->anyOf !== null || $this->allOf !== null) { Logger::warning($this->context, 'Complex types can not be part of query or URL parameters. Falling back to string due to undefined serialization!'); diff --git a/tests/openapi-administration.json b/tests/openapi-administration.json index 98e48c69..ca4f4d35 100644 --- a/tests/openapi-administration.json +++ b/tests/openapi-administration.json @@ -7656,11 +7656,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -7950,11 +7946,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -7964,11 +7956,8 @@ "required": true, "deprecated": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean", + "deprecated": true } }, { @@ -8260,11 +8249,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -8274,11 +8259,8 @@ "required": true, "deprecated": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean", + "deprecated": true } }, { diff --git a/tests/openapi-full.json b/tests/openapi-full.json index e138a8a8..ff0935d8 100644 --- a/tests/openapi-full.json +++ b/tests/openapi-full.json @@ -7843,11 +7843,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -8137,11 +8133,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -8151,11 +8143,8 @@ "required": true, "deprecated": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean", + "deprecated": true } }, { @@ -8447,11 +8436,7 @@ "description": "Not deprecated", "required": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean" } }, { @@ -8461,11 +8446,8 @@ "required": true, "deprecated": true, "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] + "type": "boolean", + "deprecated": true } }, {