JsonSchema-JavaUI / sf-java-ui

Json Schema Form java based library allow developers to define schema and form using field annotations
MIT License
24 stars 16 forks source link

JSON generated from TitleMap is Invalid #79

Closed lbispham closed 6 years ago

lbispham commented 6 years ago

Description

I am generating a RadioBox from a TitleMap. The form JSON is invalid.

Steps to Reproduce

  1. public class UserValues implements ValuesContainer {

    @Override public Map<String, String> getValues() { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.put("Custom", "Custom"); builder.put("Standard", "Standard"); return builder.build(); } }

  2. @RadioBox(title = "Choose a setting", titleMap = UserValues .class) private String choose;

Expected behavior: [What you expect to happen]

I expect my JSON for the form to look like this:

{ "key": "choose", "readOnly": false, "type": "radios", "titleMap": [ { "name": "Custom", "value": "Custom" }, { "name": "Standard", "value": "Standard" } ] }

Actual behavior: [What actually happens]

Instead the JSON is invalid and looks like this (no quotation marks around the values in the titleMap):

{ "key": "choose", "readOnly": false, "type": "radios", "titleMap": [ { "name": "Custom", "value": Custom }, { "name": "Standard", "value": Standard } ] }

Versions

1.0.0

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

SaifJerbi commented 6 years ago

Hi @lbispham,

I can't reproduce the issue. I used the same implementation but the issue is not reproduced.

// My field
@RadioBox(title="Gender", titleMap=GenderTitleMap.class)
private String gender;

// My Map values
@Override
public Map<String, String> getValues() {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    builder.put("Male", "Male");
    builder.put("Female", "Female");
    return builder.build();
}

I got the json below:

// The result
[
  {
    "key": "gender",
    "readOnly": false,
    "type": "radios",
    "titleMap": [
      {
        "name": "Male",
        "value": "Male"
      },
      {
        "name": "Female",
        "value": "Female"
      }
    ]
  }
]

Can you please try to use the demo app and try to reproduce your issue or fill more details about your app environment