winget-run / api

winget.run rest api
45 stars 4 forks source link

v2/packages api returns duplicated keys 'UpdatedAt' and 'updatedAt' #163

Open peacemaker360 opened 2 years ago

peacemaker360 commented 2 years ago

Hi team,

It seems that when searching for a given package, the packages API might return a duplicate key for "UpdatedAt" property.

Reproduce (pwsh):

$apiURL = "https://api.winget.run/v2/packages"

$app = "Microsoft.VisualStudioCode"
$searchQuery = "?query=$app&Ensurecontains=true&sample=1"

$results = Invoke-RestMethod -Uri "$apiURL$searchQuery" -Method Get
ConvertFrom-Json $results

Error: ConvertFrom-Json : Cannot convert the JSON string because a dictionary that was converted from the string contains the duplicated keys 'UpdatedAt' and 'updatedAt'

Returned value from API:

{
  "Packages": [
    {
      "Id": "Microsoft.VisualStudioCode",
      "Versions": [
        "1.63.2",
        "..."
      ],
      "Latest": {
        "Name": "Microsoft Visual Studio Code",
        "Publisher": "Microsoft Corporation",
        "Tags": ["developer-tools", "editor"],
        "Description": "Microsoft Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Microsoft Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.",
        "Homepage": "https://code.visualstudio.com",
        "LicenseUrl": "https://code.visualstudio.com/license"
      },
      "Featured": true,
      "UpdatedAt": "2021-12-24T00:18:15.055791400Z",
      "CreatedAt": "2021-12-24T00:18:15.055795Z",
      "Banner": "https://cdn.discordapp.com/attachments/722206274363588608/748629192635187200/unknown.png",
      "Logo": "https://cdn.discordapp.com/attachments/722206274363588608/748624788414660618/vscode.svg",
      "updatedAt": "2021-12-24T17:03:49.000Z",
      "SearchScore": 12.12846870226944
    },
    {
      "Id": "Microsoft.VisualStudioCode.Insiders",
      "Versions": [
        "1.64.0",
        "1.63.0",
         "..."
      ],
      "Latest": {
        "Name": "Microsoft Visual Studio Code Insiders",
        "Publisher": "Microsoft Corporation",
        "Tags": ["developer-tools", "editor"],
        "Description": "Microsoft Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Microsoft Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.",
        "Homepage": "https://code.visualstudio.com",
        "LicenseUrl": "https://code.visualstudio.com/license/insiders"
      },
      "Featured": false,
      "UpdatedAt": "2021-12-24T00:18:11.536971600Z",
      "CreatedAt": "2021-12-24T00:18:11.536974900Z",
      "SearchScore": 12.066488739627225
    }
  ],
  "Total": 2
}

Would it be possible to ensure the results do not contain duplicate keys? Or is this an issue with the package, "Microsoft.VisualStudioCode" rather than the API?

Thanks for your help!

Kind regards, Fabian

HarryPioter commented 4 months ago

As walkaround i use $jsonString = $jsonString -replace '"createdAt":', '"CreatedAt":'