Skip to content

fix(ids): keep minOccurs and maxOccurs of a specification on load and export - #851

Open
helenkwok wants to merge 1 commit into
ThatOpen:mainfrom
helenkwok:fix/ids-specification-occurs
Open

helenkwok wants to merge 1 commit into
ThatOpen:mainfrom
helenkwok:fix/ids-specification-occurs

Conversation

@helenkwok

Copy link
Copy Markdown
Contributor

Description

Part of #831 (the "Specification cardinality" row).

The cardinality of a specification is set by minOccurs and maxOccurs on its <applicability>: required is 1 / unbounded, optional is 0 / unbounded, prohibited is 0 / 0 (IDS developer guide, Optionality). load() ignored both, and IDSSpecification.serialize() always wrote minOccurs="1" maxOccurs="unbounded". So an optional or prohibited specification came back from an export as a required one.

IDSSpecification now has minOccurs (default 1) and maxOccurs (default "unbounded"). load() reads them from the applicability and serialize() writes them back. No result changes: test() is untouched, evaluating the cardinality is a separate change.

Additional context

  • New specification-occurs.test.ts: the defaults, and optional and prohibited surviving a load and an export. All three tests fail on main (minOccurs is undefined) and pass with the change.
  • vitest --run on the IDS folder: all pass. tsc -p tsconfig-build.json --noEmit is clean.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

… export

The cardinality of a specification is set by minOccurs and maxOccurs on its applicability: required is 1 and unbounded, optional is 0 and unbounded, prohibited is 0 and 0. They were ignored on load and always written as 1 and unbounded on export, so an optional or prohibited specification came back required.

Read both on load into IDSSpecification.minOccurs and maxOccurs (default 1 and unbounded) and write them back on export.

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.

1 participant