Repository navigation
fix(register): drop null JSON-Schema keywords so the E2E seed can create elements #1295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WilcoLouwerse
wants to merge
3
commits into
development
Choose a base branch
from
fix/register-null-schema-keywords
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
8c839b5
fix(register): drop null JSON-Schema keywords so OpenRegister accepts…
WilcoLouwerse 4a55e91
docs(tests): name the Guzzle version composer.json requires
WilcoLouwerse 23c2003
fix(register): carry the schema bumps in the fragments that hold the …
WilcoLouwerse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Guard: no register schema may carry a null JSON-Schema validation keyword. | ||
| * | ||
| * OpenRegister's validator (opis/json-schema) rejects a null where a keyword | ||
| * wants a number ("minimum must contain a valid number"), so a schema with | ||
| * hardValidation refuses every object. The register file once carried | ||
| * `"minimum": null` and similar on ~420 properties and the E2E seed failed. | ||
| * | ||
| * @category Tests | ||
| * @package OCA\Stackiq\Tests\Unit\Settings | ||
| * @author Conduction b.v. <info@conduction.nl> | ||
| * @copyright 2026 Conduction B.V. | ||
| * @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 | ||
| * @link https://github.com/ConductionNL/stackiq | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Stackiq\Tests\Unit\Settings; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| /** | ||
| * Scans the register file and its register.d fragments for null keywords. | ||
| */ | ||
| class RegisterNullKeywordsTest extends TestCase { | ||
| private const KEYWORDS = [ | ||
| 'minimum', | ||
| 'maximum', | ||
| 'exclusiveMinimum', | ||
| 'exclusiveMaximum', | ||
| 'multipleOf', | ||
| 'minLength', | ||
| 'maxLength', | ||
| 'minItems', | ||
| 'maxItems', | ||
| 'minProperties', | ||
| 'maxProperties', | ||
| ]; | ||
|
|
||
| /** | ||
| * Collect the paths of null validation keywords below a node. | ||
| * | ||
| * @param mixed $node The decoded JSON node. | ||
| * @param string $path The path to the node. | ||
| * | ||
| * @return array<int,string> The offending paths. | ||
| */ | ||
| private function findNullKeywords(mixed $node, string $path): array { | ||
| $found = []; | ||
| if (is_array($node) === false) { | ||
| return $found; | ||
| } | ||
|
|
||
| foreach ($node as $key => $value) { | ||
| $child = $path.'/'.$key; | ||
| if ($value === null && in_array($key, self::KEYWORDS, true) === true) { | ||
| $found[] = $child; | ||
| continue; | ||
| } | ||
|
|
||
| $found = array_merge($found, $this->findNullKeywords($value, $child)); | ||
| } | ||
|
|
||
| return $found; | ||
| }//end findNullKeywords() | ||
|
|
||
| /** | ||
| * No schema in the register or its fragments carries a null keyword. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function testNoSchemaCarriesNullValidationKeywords(): void { | ||
| $dir = __DIR__.'/../../../lib/Settings'; | ||
| $files = array_merge([$dir.'/softwarecatalogus_register.json'], glob($dir.'/register.d/*.json') ?: []); | ||
|
|
||
| $found = []; | ||
| foreach ($files as $file) { | ||
| $this->assertFileExists($file); | ||
| $decoded = json_decode((string)file_get_contents($file), true); | ||
| $this->assertIsArray($decoded, basename($file).' must be valid JSON'); | ||
| $schemas = $decoded['components']['schemas'] ?? []; | ||
| $found = array_merge($found, $this->findNullKeywords($schemas, basename($file))); | ||
| } | ||
|
|
||
| $this->assertSame([], array_slice($found, 0, 10), 'Null validation keywords make OpenRegister refuse the schema (showing first 10)'); | ||
| }//end testNoSchemaCarriesNullValidationKeywords() | ||
| }//end class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.