Skip to content

Commit 26d8a91

Browse files
Merge pull request #268 from nextcloud/fix/openapitype/remove-boolean-parameter-quirk
2 parents aa4b675 + df8ddfc commit 26d8a91

File tree

3 files changed

+14
-62
lines changed

3 files changed

+14
-62
lines changed

src/OpenApiType.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@ public function __construct(
6464

6565
public function toArray(bool $isParameter = false): array|stdClass {
6666
if ($isParameter) {
67-
if ($this->type === 'boolean') {
68-
return (new OpenApiType(
69-
context: $this->context,
70-
type: 'integer',
71-
nullable: $this->nullable,
72-
hasDefaultValue: $this->hasDefaultValue,
73-
defaultValue: $this->hasDefaultValue ? ($this->defaultValue === true ? 1 : 0) : (null),
74-
description: $this->description,
75-
enum: [0, 1],
76-
))->toArray($isParameter);
77-
}
78-
7967
if ($this->type === 'object' || $this->ref !== null || $this->anyOf !== null || $this->allOf !== null) {
8068
Logger::warning($this->context, 'Complex types can not be part of query or URL parameters. Falling back to string due to undefined serialization!');
8169

tests/openapi-administration.json

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7656,11 +7656,7 @@
76567656
"description": "Not deprecated",
76577657
"required": true,
76587658
"schema": {
7659-
"type": "integer",
7660-
"enum": [
7661-
0,
7662-
1
7663-
]
7659+
"type": "boolean"
76647660
}
76657661
},
76667662
{
@@ -7950,11 +7946,7 @@
79507946
"description": "Not deprecated",
79517947
"required": true,
79527948
"schema": {
7953-
"type": "integer",
7954-
"enum": [
7955-
0,
7956-
1
7957-
]
7949+
"type": "boolean"
79587950
}
79597951
},
79607952
{
@@ -7964,11 +7956,8 @@
79647956
"required": true,
79657957
"deprecated": true,
79667958
"schema": {
7967-
"type": "integer",
7968-
"enum": [
7969-
0,
7970-
1
7971-
]
7959+
"type": "boolean",
7960+
"deprecated": true
79727961
}
79737962
},
79747963
{
@@ -8260,11 +8249,7 @@
82608249
"description": "Not deprecated",
82618250
"required": true,
82628251
"schema": {
8263-
"type": "integer",
8264-
"enum": [
8265-
0,
8266-
1
8267-
]
8252+
"type": "boolean"
82688253
}
82698254
},
82708255
{
@@ -8274,11 +8259,8 @@
82748259
"required": true,
82758260
"deprecated": true,
82768261
"schema": {
8277-
"type": "integer",
8278-
"enum": [
8279-
0,
8280-
1
8281-
]
8262+
"type": "boolean",
8263+
"deprecated": true
82828264
}
82838265
},
82848266
{

tests/openapi-full.json

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7843,11 +7843,7 @@
78437843
"description": "Not deprecated",
78447844
"required": true,
78457845
"schema": {
7846-
"type": "integer",
7847-
"enum": [
7848-
0,
7849-
1
7850-
]
7846+
"type": "boolean"
78517847
}
78527848
},
78537849
{
@@ -8137,11 +8133,7 @@
81378133
"description": "Not deprecated",
81388134
"required": true,
81398135
"schema": {
8140-
"type": "integer",
8141-
"enum": [
8142-
0,
8143-
1
8144-
]
8136+
"type": "boolean"
81458137
}
81468138
},
81478139
{
@@ -8151,11 +8143,8 @@
81518143
"required": true,
81528144
"deprecated": true,
81538145
"schema": {
8154-
"type": "integer",
8155-
"enum": [
8156-
0,
8157-
1
8158-
]
8146+
"type": "boolean",
8147+
"deprecated": true
81598148
}
81608149
},
81618150
{
@@ -8447,11 +8436,7 @@
84478436
"description": "Not deprecated",
84488437
"required": true,
84498438
"schema": {
8450-
"type": "integer",
8451-
"enum": [
8452-
0,
8453-
1
8454-
]
8439+
"type": "boolean"
84558440
}
84568441
},
84578442
{
@@ -8461,11 +8446,8 @@
84618446
"required": true,
84628447
"deprecated": true,
84638448
"schema": {
8464-
"type": "integer",
8465-
"enum": [
8466-
0,
8467-
1
8468-
]
8449+
"type": "boolean",
8450+
"deprecated": true
84698451
}
84708452
},
84718453
{

0 commit comments

Comments
 (0)