amzn / selling-partner-api-models

This repository contains OpenAPI models for developers to use when developing software to call Selling Partner APIs.
Apache License 2.0
610 stars 732 forks source link

Incorrect attribute mappings in the flat file product attribute map spreadsheet #4264

Open jlevers opened 1 week ago

jlevers commented 1 week ago

Some of the attribute mappings in the flat file product attribute mappings file (available here) are incorrect, because they're missing an integer path component on some attributes that the product type JSON schema defines as a nested array.

For example, the battery_weight and battery_weight_unit_of_measure flat file feed columns are mapped like so:

Flat File Attribute Name,Flat File Attribute Value,JSON Pointer,JSON Value
battery_weight,,/attributes/battery/0/weight/value,
battery_weight_unit_of_measure,,/attributes/battery/0/weight/unit,

If I use those mappings, I get an error when I call the Listings API. That's because the definition of the weight property of the battery product type attribute in the product type JSON schema looks like this:

{
    "title": "Battery Weight",
    "description": "Provide the total net weight of the batteries included. This is the weight of the standalone batteries not including packaging or the device it may be used in",
    "examples": [
        "2.5 Grams"
    ],
    "type": "array",
    "minItems": 1,
    "maxItems": 1,
    "items": {
        "type": "object",
        "required": [
            "unit",
            "value"
        ],
        "properties": {
            "value": {
                "title": "Battery Weight",
                "description": "Provide the total net weight (numeric value) of the batteries included. This is the weight of the standalone batteries not including packaging or the device it may be used in.",
                "editable": true,
                "hidden": false,
                "examples": [
                    "2.5"
                ],
                "type": "number",
                "minimum": 0,
                "maxLength": 5000
            },
            "unit": {
                "title": "Battery Weight Unit",
                "description": "Provide unit for battery weight",
                "editable": true,
                "hidden": false,
                "examples": [
                    "Grams"
                ],
                "type": "string",
                "enum": [
                    "grams",
                    "hundredths_pounds",
                    "kilograms",
                    "milligrams",
                    "ounces",
                    "pounds",
                    "tons"
                ],
                "enumNames": [
                    "Grams",
                    "Hundredths Pounds",
                    "Kilograms",
                    "Milligrams",
                    "Ounces",
                    "Pounds",
                    "Tons"
                ]
            }
        },
        "additionalProperties": false
    }
}

That schema says that battery weight info must be sent in a JSON patch object that looks like this:

{
    "op": "replace",
    "path": "/attributes/battery",
    "value": [
        {
            "weight": [
                {
                    "value": 25.5,
                    "unit": "LB"
                }
            ]
        }
    ]
}

Which means that these are correct mappings for those properties:

Flat File Attribute Name,Flat File Attribute Value,JSON Pointer,JSON Value
battery_weight,,/attributes/battery/0/weight/0/value,
battery_weight_unit_of_measure,,/attributes/battery/0/weight/0/unit,

Interestingly, the XML mappings file has these two paths correct. I'm guessing there are many more attributes with similar issues, although I have no good way of checking which ones they are. It would be great to get this resolved as quickly as possible, because it makes building an automated solution to mapping product attributes from the old flat-file format to the new JSON-based format inevitably filled with bugs.

ritikacd commented 6 days ago

Hello @jlevers

Thank you for raising this issue and providing the right mappings. We will share the feedback with the team to investigate all the JSON mapping paths.

As a best practice, it is recommended to validate the JSON Schemas against the Product Type Definitions API response to ensure they are in the correct format.

Thanks, Ritika Chaudhary Selling Partner API Developer Services