watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
590 stars 533 forks source link

[discovery] Rename 'json' to 'json_normalizations' in Configuration #517

Closed maniax89 closed 7 years ago

maniax89 commented 7 years ago

Description

Users are unable to create a configuration with json normalization operations because the serialized name is incorrect.

Steps to reproduce

  1. Create a configuration file with some json normalization, example:
    {
      "name": "my_config",
      "conversions": {
        "json_normalizations": [
          {
            "operation": "copy",
            "source_field": "some_field",
            "destination_field": "other_field"
          }
        ]
    }
  2. Read in the file with the SDK
     Configuration config = GsonSingleton.getGson().fromJson(new FileReader("/path/to/config-file.json"), Configuration.class);
  3. Attempt to create a configuration
    Discovery discovery = new Discovery("2016-12-15");
    discovery.setEndpoint("https://gateway.watsonplatform.net/discovery/api");
    discovery.setUsernameAndPassword("my_username", "my_password");
    String environmentId = "my_environment_id";
    CreateConfigurationRequest.Builder createBuilder = new CreateConfigurationRequest.Builder(environmentId);
     createBuilder.configuration(config);
     CreateConfigurationResponse createResponse = discovery.createConfiguration(createBuilder.build()).execute();
  4. Expected config is not returned on GET requests:
    GetConfigurationRequest getRequest = new GetConfigurationRequest.Builder(environmentId).build();
    GetConfigurationResponse getResponse = discovery.getConfiguration(getRequest).execute();
    System.out.println(getResponse); //does not have expected config, should be same as above with 'conversions.json_normalizations' key

Solution

When reporting a bug, please be sure to include the following:

Mikemosca commented 7 years ago

@maniax89 - hi Andrew

Is the configuration schema defined anywhere in the documentation? Your test case works if you use "json" instead of "json_normalizations". I just want to make sure the schema calls for "json_normalizations" before I change it. Thanks!

{
  "name": "my_config",
  "conversions": {
    "json_normalizations": [
      { ...

maniax89 commented 7 years ago

yes it calls for json_normalizations - see here https://watson-api-explorer.mybluemix.net/apis/discovery-v1#!/Configurations/get_v1_environments_environment_id_configurations_configuration_id

Mikemosca commented 7 years ago

Thanks, I was looking in the API reference.

Mikemosca commented 7 years ago

In review - https://github.com/watson-developer-cloud/java-sdk/pull/597