Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
* Validation and progress contracts
*
* @psalm-type LibresignPolicyScope = 'system'|'group'|'user'
* @psalm-type LibresignEffectivePolicyValue = null|bool|int|float|string|array<string, mixed>
* @psalm-type LibresignEffectivePolicyValue = null|bool|numeric|string|array<string, mixed>
* @psalm-type LibresignEffectivePolicyMeta = array{
* defaultSystemValue?: LibresignEffectivePolicyValue,
* appConfigKey?: string,
Expand Down
9 changes: 2 additions & 7 deletions openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,12 @@
},
"EffectivePolicyValue": {
"nullable": true,
"anyOf": [
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "number",
"format": "double"
"type": "number"
},
{
"type": "string"
Expand Down
9 changes: 2 additions & 7 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -1072,17 +1072,12 @@
},
"EffectivePolicyValue": {
"nullable": true,
"anyOf": [
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "number",
"format": "double"
"type": "number"
},
{
"type": "string"
Expand Down
9 changes: 2 additions & 7 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,17 +799,12 @@
},
"EffectivePolicyValue": {
"nullable": true,
"anyOf": [
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "number",
"format": "double"
"type": "number"
},
{
"type": "string"
Expand Down
44 changes: 44 additions & 0 deletions tests/php/openapi/OpenApiPolicyNumberUnionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Libresign\Tests\OpenApi;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class OpenApiPolicyNumberUnionTest extends TestCase {
public static function specificationProvider(): array {
return [
'default scope' => ['openapi.json'],
'administration scope' => ['openapi-administration.json'],
'full scope' => ['openapi-full.json'],
];
}

#[DataProvider('specificationProvider')]
public function testPolicyValueUsesDisjointJsonNumberBranch(string $file): void {
$source = file_get_contents(dirname(__DIR__, 3) . '/' . $file);
self::assertNotFalse($source);

$spec = json_decode($source, true, 512, JSON_THROW_ON_ERROR);
$schema = $spec['components']['schemas']['EffectivePolicyValue'] ?? null;
self::assertIsArray($schema);
self::assertArrayNotHasKey('anyOf', $schema);
self::assertArrayHasKey('oneOf', $schema);

// JSON numbers include both integers and decimals. A separate integer
// branch would overlap with number and change oneOf semantics.
$types = array_map(
static fn (array $item): ?string => $item['type'] ?? null,
$schema['oneOf'],
);
sort($types);
self::assertSame(['boolean', 'number', 'object', 'string'], $types);
}
}
1 change: 1 addition & 0 deletions tests/php/openapi/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<testsuite name="openapi">
<file>OpenApiFunctionalTagsTest.php</file>
<file>OpenApiGenerationTest.php</file>
<file>OpenApiPolicyNumberUnionTest.php</file>
<file>OpenApiRequestHeadersTest.php</file>
</testsuite>
</testsuites>
Expand Down
Loading