refactor(docs): read documented enum values through one shared reader - #12293
Conversation
|
This pull request is part of a Mergify stack:
|
Merge Protections🔴 2 of 7 protections blocking · waiting on 👀 reviews
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
Show 5 satisfied protections🟢 ⛓️ Depends-On RequirementsRequirement based on the presence of
🟢 🤖 Continuous Integration
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
b56a1a0 to
810fd13
Compare
5e644c7 to
dc555d0
Compare
Revision history
|
dc555d0 to
fad7e3e
Compare
810fd13 to
3cf3096
Compare
3cf3096 to
3c3d836
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a shared, schema-shape-tolerant reader for “choice sets” (enums + per-value documentation) to keep docs rendering stable across an engine-side schema migration from x-enum-descriptions to x-mergify-enum, including cases where enums are hoisted behind $ref.
Changes:
- Added
readEnumChoices(and supporting$refresolution/metadata collection) to handleenum,const, andanyOf/oneOfchoice shapes across both metadata formats. - Added Vitest coverage to pin expected behavior for migration edge cases (ref siblings, hoisted enums, misaligned positional metadata, etc.).
- Refactored
QueueDequeueReasonsto use the shared reader rather than bespoke enum/description extraction.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/util/enumChoices.ts | New shared enum-choice reader with $ref resolution and merged legacy/target metadata handling. |
| src/util/enumChoices.test.ts | New unit tests covering multiple schema shapes and migration failure modes. |
| src/components/Tables/QueueDequeueReasons.tsx | Switched dequeue reason table generation to readEnumChoices for migration-safe rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3c3d836 to
f747840
Compare
f747840 to
4b1ec1f
Compare
The engine is changing how it publishes per-value documentation for a schema's choice set, moving from an `x-enum-descriptions` map to a positional `x-mergify-enum` array that also carries a display title and a deprecation flag. Schema syncs land as direct pushes to main, so the docs repo cannot assume both sides move together. Introduce `readEnumChoices`, which tolerates every shape a synced schema can be in during that migration: values as a flat `enum`, a `const`, or the `anyOf` of branches a composed `Literal` produces, with the node — or any single branch of it — either inline or behind a `$ref`. Hoisting repeated enums into shared components is what removes the duplicated blocks from the published schema, and a reader that followed only the property node would silently render an empty table once that happens. Three things the shape change makes possible that the map could not, and which are handled explicitly because each fails silently: - Metadata can sit on the referring node as a `$ref` sibling rather than on the target, which is how pydantic publishes an annotation for a hoisted type. Both are consulted, nearest first. - A positional array can fall out of alignment with `enum` in a way a keyed map never could. A length mismatch is treated as unusable rather than shifting every description onto the wrong value. - The two shapes can coexist on one node mid-migration, so they are merged rather than treated as alternatives. Ref resolution uses the `jsonpointer` the sibling readers already use: hand-decoding each segment raises `URIError` on a pointer containing a stray `%`, which would break the never-throws contract this reader depends on to degrade instead of failing the build. The dequeue reason table moves onto it here; the batch status table is written against it from the start in a later commit. Rendered output is unchanged. Part of MRGFY-8330 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Change-Id: Ie539de06bf3391eb4390333810cda6e8f131b1e6
4b1ec1f to
b5e84ba
Compare
The engine is changing how it publishes per-value documentation for a
schema's choice set, moving from an
x-enum-descriptionsmap to apositional
x-mergify-enumarray that also carries a display title and adeprecation flag. Schema syncs land as direct pushes to main, so the docs
repo cannot assume both sides move together.
Introduce
readEnumChoices, which tolerates every shape a synced schemacan be in during that migration: values as a flat
enum, aconst, orthe
anyOfof branches a composedLiteralproduces, with the node — orany single branch of it — either inline or behind a
$ref. Hoistingrepeated enums into shared components is what removes the duplicated
blocks from the published schema, and a reader that followed only the
property node would silently render an empty table once that happens.
Three things the shape change makes possible that the map could not, and
which are handled explicitly because each fails silently:
$refsibling rather thanon the target, which is how pydantic publishes an annotation for a
hoisted type. Both are consulted, nearest first.
enumin a way akeyed map never could. A length mismatch is treated as unusable rather
than shifting every description onto the wrong value.
merged rather than treated as alternatives.
Ref resolution uses the
jsonpointerthe sibling readers already use:hand-decoding each segment raises
URIErroron a pointer containing astray
%, which would break the never-throws contract this readerdepends on to degrade instead of failing the build.
The dequeue reason table moves onto it here; the batch status table is
written against it from the start in a later commit. Rendered output is
unchanged.
Part of MRGFY-8330
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Depends-On: #12299