Skip to content

fix: select category templates from the schema allOf like the wiki - #221

Open
LukasGold wants to merge 4 commits into
mainfrom
fix/category-template-selection
Open

LukasGold wants to merge 4 commits into
mainfrom
fix/category-template-selection

Conversation

@LukasGold

@LukasGold LukasGold commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #220
Related: #215

Depends on #216. This branch is based on the branch of that pull request, so the diff against main contains its commit until it is merged.

Changes

  • store_entity collects the category templates from the allOf chain of the meta category schemas, in the order of the wiki form editor, instead of walking subclass_of. The walk includes every entry of properties and the items of each property, after allOf, oneOf, anyOf, definitions and $defs. A referenced schema is walked only at its first occurrence.
  • The definitions section mode is chosen when Category:OSWffe74f291d354037b318c422591c5023 (CharacteristicType) is in that list, not by the model class of the entity.
  • Ports of the wiki post processing: the reset of the generated @context block, the merge of the generated @context into the first object block, and the removal of root members that the generated section defines.
  • A warning is logged when the jsonschema of a meta category page is missing.

Rationale

Category:Category has an allOf to CharacteristicType and no subclass_of, so the subclass_of walk never reached the CharacteristicType template. The wiki follows the schema allOf.

Tests

  • New regression test tests/test_store_entity_category_templates.py. It stores the after jsondata of two saved Category pages (PhysicalItem and PhysicalItemType; the repository owner stated that they were saved unchanged through the form editor, which was not verified here) on top of the before jsonschema, offline, and expects the jsonschema of the after state. Both pages are equal to the form-editor result.
  • Unit tests for the template order, the walk through properties and items, the @context reset, the removal of root members and the warning.
  • tests/test_store_entity_keeps_jsonschema.py now serves a meta category schema with an allOf to CharacteristicType where it expects the definitions section mode.
  • Full offline suite: 815 passed.

Limits

  • A /wiki/<title>?action=raw reference is followed only for category pages. For example /wiki/JsonSchema:Label?action=raw is not followed. A Special:SlotResolver reference is followed for any page.
  • The @context reset, the @context merge and the removal of root members run only in definitions section mode.
  • Namespaces other than Category are unchanged: store_entity generates no schema there, the wiki does.

- pass target_schema= instead of the ignored schema= (#215)
- replace $defs/generated in DEFINITIONS_SECTION mode instead of merging
- add offline regression tests through store_entity
)

- collect templates from the meta category allOf chain, wiki order
- pick the definitions section mode by CharacteristicType in the list
- port @context reset and merge, and superseded root member removal
- warn when a meta category schema is missing
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Release preview

Merging this PR would release v2.8.3 (current: v2.8.2).

Changelog preview (truncated)
## v2.8.3 (2026-11-05)

### Bug Fixes

- Follow properties and items when collecting category templates
  ([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
  [`55e500e`](https://github.com/OpenSemanticLab/osw-python/commit/55e500efb896f0a3d6bde98409b3a6f43a652bdc))

- Keep the stored jsonschema when store_entity regenerates it
  ([`9b76a8f`](https://github.com/OpenSemanticLab/osw-python/commit/9b76a8fbeb813b34c4881b54d329e9e837b08f95))

- Select category templates from the schema allOf like the wiki
  ([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
  [`9f606f4`](https://github.com/OpenSemanticLab/osw-python/commit/9f606f48fefd640cca48e6718f1a92eca118da6b))

### Documentation

- State which schema references the template walk follows
  ([#220](https://github.com/OpenSemanticLab/osw-python/pull/220),
  [`799bc07`](https://github.com/OpenSemanticLab/osw-python/commit/799bc07952aac7e6ab579bc127c5cb3000710491))

Preview via python-semantic-release and conventional commits.

…220)

- walk properties and items after allOf, definitions and $defs
- a referenced schema is walked at its first occurrence only
- update the docstring

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

store_entity selects category templates differently from the wiki form editor

1 participant