Skip to content
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

fix(canonical-title-map): add use case for enumNames #8

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open

fix(canonical-title-map): add use case for enumNames #8

wants to merge 2 commits into from

Conversation

jmfrancois
Copy link

Description

Add support case for enumNames.
Spec: json-schema-org/json-schema-spec#57

We have some schemas with the following shape:

{
  "jsonSchema": {
    "type": "object",
    "title": "Datalist",
    "properties": {
      "test": {
        "type": "string",
        "enum": [ "a", "p", "b", "c", "l", "g" ],
        "enumNames": [ "Apple", "Pine[apple]", "Banana", "Cher[ry", "Lemo}n", "Grapefruit" ]
      }
    },
    "required": [
      "test"
    ]
  },
  "uiSchema": [
    {
      "key": "test",
      "title": "Datalist with named options",
      "widget": "datalist"
    }
  ],
  "properties": {
    "test": "Pine[apple]"
  }
}

This raise exception with the current implementation because we have an array of value for the titleMap;

Checklist

  • I have read and understand the CONTRIBUTIONS.md file
  • I have searched for and linked related issues
  • I have created test cases to ensure quick resolution of the PR is easier
  • I am NOT targeting master branch
  • I did NOT include the dist folder in my PR

@json-schema-form/angular-schema-form-lead

@@ -14,6 +14,17 @@ export default function(titleMap: Array<any>, originalEnum?: any) {
});
}
return canonical;
} else if (originalEnum) {
const canonical = [];
Copy link

@scottux scottux Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition of canonical doesn't seem to be used. I think it is safe to remove it.

if (typeof titleMap[index] === 'string') {
return {
name: titleMap[index],
value,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove trailing comma here.

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.

2 participants