Add support for v2 schema enum choice lists#42
Open
doneill wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds V2 CHOICE_LIST support for enum-based schemas with x-enumExtra, aligning UI schema generation with the newer EarthRanger schema format while preserving legacy oneOf handling.
Changes:
- Accepts
enumchoice list structures during V2 schema validation. - Maps enum values plus
x-enumExtra.displayinto JSONForms control options. - Adds tests for single-select, multi-select, fallback labels, backward compatibility, and immutability.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/v2/utils.ts |
Adds enum-to-options.oneOf mapping for choice controls. |
src/v2/generateUISchema.ts |
Extends CHOICE_LIST validation to accept enum arrays. |
src/common/types.ts |
Updates V2 property typing for enum/x-enumExtra choice items. |
test/v2.test.ts |
Adds coverage for enum choice-list generation behavior. |
package.json |
Bumps package version. |
package-lock.json |
Updates lockfile package metadata, but remains out of sync with package.json. |
yarn.lock |
Updates dependency lock entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+100
to
+104
| const enumItem = anyOfSource?.find((a: any) => a.enum && a["x-enumExtra"]); | ||
| if (enumItem) { | ||
| control.options!.oneOf = enumItem.enum.map((value: any) => ({ | ||
| const: value, | ||
| title: enumItem["x-enumExtra"][value]?.display ?? String(value), |
Comment on lines
+49
to
+51
| const isValidChoiceItem = (anyOfItem: any): boolean => | ||
| (anyOfItem.oneOf && Array.isArray(anyOfItem.oneOf)) || | ||
| (anyOfItem.enum && Array.isArray(anyOfItem.enum)); |
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.
Add support for #41
Proposed Changes
src/v2/utils.ts
createControlextractsx-enumExtrafrom the property'sanyOfand injects the following into the contol whenenumpresentsrc/common/generateUISchema.ts
enumas valid choice itemImplementation Test
In React Native client app, e.g. EarthRanger
-Verify the app continues to display
anyOfchoice lists andenumchoice listsUnit Tests