GoogleChrome / chrome-types

Code to parse Chrome's internal extension type definitions—published on NPM as chrome-types
https://www.npmjs.com/package/chrome-types
Apache License 2.0
189 stars 30 forks source link

Fix rendering of chrome.gcm senderIds type. #52

Closed oliverdunk closed 1 year ago

oliverdunk commented 1 year ago

Overview

Improves rendering of the chrome.gcm senderIds type in the chrome.gcm.register function.

Old New
Screenshot 2023-06-07 at 11 01 39 Screenshot 2023-06-07 at 11 00 44

Thought Process

When generating the chrome.gcm docs, we were previously seeing the following in the gcm.json spec:

{
  "name": "senderIds",
  "type": "array",
  "items": {
    "type": "string",
    "minLength": 1
  },
  "minItems": 1,
  "maxItems": 100,
},

And generating a union of all possible array lengths.

While it would be nice to have proper rendering for this in the future (e.g a min and max length tag) this PR implements a temporary solution where we simply collapse the type to X[] when we see more than 10 (an arbitrary but reasonable sound number) possible types. This seems reasonable since chrome.gcm is currently the only API with this problem (I checked) and the comments already explain the limit in detail.

Additional Details

Fixes https://github.com/GoogleChrome/developer.chrome.com/issues/1850 Fixes https://github.com/GoogleChrome/developer.chrome.com/issues/5176

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.52 :tada:

Comparison is base (98aee76) 35.61% compared to head (8b68314) 36.14%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #52 +/- ## ========================================== + Coverage 35.61% 36.14% +0.52% ========================================== Files 21 21 Lines 4015 4023 +8 Branches 185 188 +3 ========================================== + Hits 1430 1454 +24 + Misses 2585 2569 -16 ``` | [Impacted Files](https://app.codecov.io/gh/GoogleChrome/chrome-types/pull/52?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleChrome) | Coverage Δ | | |---|---|---| | [tools/lib/render-context.js](https://app.codecov.io/gh/GoogleChrome/chrome-types/pull/52?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleChrome#diff-dG9vbHMvbGliL3JlbmRlci1jb250ZXh0Lmpz) | `60.36% <100.00%> (+2.52%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.