Implement extend-schemas-in-register-service: honour _extend on RegisterService end-to-end (#1428)#1430
Open
rjzondervan wants to merge 1 commit intodevelopmentfrom
Open
Conversation
Honour `_extend` on `RegisterService` end-to-end so DI consumers receive the same expanded schemas as HTTP callers. Schema expansion + per-schema `@self.stats` move from the controller into a new `RegisterSerializer`. What changed - New `OCA\OpenRegister\Service\Serializer\RegisterSerializer` (197 lines) with `serialize()` + `serializeMany()`. Recognises `schemas` and `@self.stats`. Preserves orphan schema IDs in original position (deliberate divergence from the pre-refactor controller, documented in proposal/design/spec). Preserves `properties` on expanded schemas; consumer-side stripping stays in the consumer (e.g. DocuDesk). - `RegisterService::findSerialized()` and `findAllSerialized()` — DI-accessible methods that orchestrate the stats fetch and delegate to the serializer. - `RegistersController::index()` now calls `findAllSerialized` and the inline expansion + per-schema stats blocks are gone. Register-level `@self.stats` (object/log/file counts) stays in the controller — out of scope for the serializer. - `RegisterMapper::find()` and `::findAll()` drop the unused `_extend` parameter; the `@SuppressWarnings(PHPMD.UnusedFormalParameter)` pragmas are removed. Service-level signatures keep `_extend` as a documented no-op placeholder for compatibility. - `SchemaMapper`'s `@method find(...)` annotation extended so PHPStan sees the full signature. - `RegisterSerializerTest` (10 unit tests) and `RegisterSerializerIntegrationTest` (4 integration tests) cover all spec scenarios. `RegisterServiceTest` and `RegistersControllerTest` updated for the new constructor + delegation pattern. - Docs: new `docs/development/Services/serializers.md`, CHANGELOG entry (Added + Breaking). Quality - PHPCS / Psalm / PHPStan clean on all touched files - Unit suite for affected files: 120/120 green inside the dev container - Integration tests: 4/4 green Follow-up - DocuDesk follow-up issue filed at ConductionNL/docudesk#120 — opens once openregister cuts a release containing this change. Closes openregister#1428
Contributor
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| composer | ✅ | ✅ 147/147 | |||
| npm | ✅ | ✅ 598/598 | |||
| PHPUnit | ❌ | ||||
| Newman | ❌ | ||||
| Playwright | ⏭️ |
Quality workflow — 2026-05-05 18:37 UTC
Download the full PDF report from the workflow artifacts.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Honours
_extendonRegisterServiceend-to-end so DI consumers (DocuDesk, OpenCatalogi, softwarecatalog) receive the same expanded schemas as the HTTPGET /api/registers?_extend=schemasendpoint. Schema expansion + per-schema@self.statsmove fromRegistersController::index()into a newRegisterSerializerin a newlib/Service/Serializer/namespace.Closes #1428.
What changed
New code
lib/Service/Serializer/RegisterSerializer.php— entity serializer withserialize()+serializeMany(). Recognisesschemasand@self.stats. Preserves orphan schema IDs in their original position (deliberate divergence from the pre-refactor controller, documented in the proposal/design/spec). Preservespropertieson expanded schemas; consumer-side stripping stays in the consumer (e.g. DocuDesk).RegisterService::findSerialized()andRegisterService::findAllSerialized()— DI-accessible methods that orchestrate the stats fetch and delegate to the serializer.Refactored
RegistersController::index()now callsfindAllSerializedfor the schema-expansion path. Inline expansion + per-schema stats loops removed. Register-level@self.stats(object/log/file counts on the register itself) stays in the controller — out of scope for the serializer.RegisterMapper::find()/::findAll()drop the unused_extendparameter; the@SuppressWarnings(PHPMD.UnusedFormalParameter)pragmas are removed. Service-levelfind()/findAll()keep_extendas a documented no-op placeholder for signature compatibility.SchemaMapper's@method find(...)annotation extended so PHPStan sees the full signature (was previouslyfind(int|string $id)only).Tests + docs
RegisterSerializerTest— 10 unit tests covering all spec scenarios (no extend, schemas, orphan-ID retention, type preservation, stats with/without orphans, unknown-key tolerance, entity-contract preservation, plus aserializeManyper-register stats routing test).RegisterSerializerIntegrationTest— 4 integration tests against a live DB (DI parity, orphan retention, stats attachment, no-extend baseline).RegisterServiceTestandRegistersControllerTestupdated for the new constructor + delegation pattern. Caught a pre-existing constructor-arg-count drift in the controller test (IGroupManagermock was missing) and fixed that too.docs/development/Services/serializers.md.CHANGELOG.mdAdded + Breaking entries.Wire-format breaking change (orphan IDs)
When a register references a schema that has been deleted, the response's
schemasfield is now a heterogeneous array of objects + bare IDs (in original order) instead of silently dropping the orphan. JSON consumers in statically-typed clients (Go, Java, Kotlin) that decodeschemasas[]Schemaneed a discriminated decoder. The DocuDesk frontend already filters viatypeof schema === 'object'and is unaffected. Documented under Risks indesign.mdand called out in the changelog.Quality
@SuppressWarnings+ reasons; pre-existing warnings on unrelated code left as-is)RegisterServiceTest21,RegistersControllerTest87,RegisterMapperTest2,RegisterSerializerTest10)RegisterSerializerIntegrationTest)Test plan
GET /api/registers?_extend=schemasagainst a register with all schemas resolvable — response is byte-equivalent to the pre-refactor happy pathGET /api/registers?_extend=schemasagainst a register with at least one deleted schema — orphan ID is retained in its original position, log warning is emittedGET /api/registers?_extend=schemas&_extend=@self.stats— each expanded schema hasstats.objects.total; the register hasstats.objects/logs/filesCross-repo follow-ups
RegisterDiscoveryService::fetchAvailableRegisters()to callfindAllSerializedonce openregister cuts a release containing this change. The one-line swap + theserializeRegister → filterSchemasrename are documented in that issue._extendtoRegisterService::findAll/findwere found in opencatalogi; softwarecatalog wasn't audited locally (separate ticket).🤖 Generated with Claude Code