Repository navigation
Add union extends discriminated union Spector scenarios - #12288
Chenjie Shi (tadelesh) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fe48cf1c-c567-4896-b51d-5ae7233ae454
commit: |
There was a problem hiding this comment.
🟢 Approval recommended
The contracts, mocks, and configuration handling are consistent, with focused regression coverage and no blocking issues identified.
0 open findings
What changed in this PR
Adds 22 Spector wire contracts for constrained discriminated unions and enables configuration-aware validation.
Changes:
- Covers inherited alternatives, discriminator variations, envelopes, and recursive containers.
- Honors scenario feature flags and reports configuration diagnostics while preserving validation behavior.
- Adds regression tests, documentation, and package changelogs.
| File | Description |
|---|---|
packages/spector/test/compile-scenario.test.ts |
Tests feature flags and validation configuration. |
packages/spector/src/spec-utils/compile-scenario.ts |
Centralizes configuration-aware compilation. |
packages/spector/src/scenarios-resolver.ts |
Uses the shared compilation helper. |
packages/spector/src/actions/validate-mock-apis.ts |
Applies configuration-aware mock validation. |
packages/spector/README.md |
Documents scenario feature flags. |
packages/http-specs/specs/type/union/discriminated/extends/tspconfig.yaml |
Enables union-extends. |
packages/http-specs/specs/type/union/discriminated/extends/mockapi.ts |
Defines mocks for all 22 contracts. |
packages/http-specs/specs/type/union/discriminated/extends/main.tsp |
Defines constrained-union scenarios. |
packages/http-specs/spec-summary.md |
Documents the new endpoints and payloads. |
.chronus/changes/spector-scenario-project-features.md |
Records the Spector validation fix. |
.chronus/changes/discriminated-union-extends-scenarios.md |
Records the new HTTP scenarios. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
Remove deferred envelope contracts and changelog examples, and use a virtual compiler filesystem in scenario configuration tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fe48cf1c-c567-4896-b51d-5ae7233ae454
|
Could we separate recursive-union coverage from explicit-null preservation?
Recursive subtype dispatch for properties, arrays and dictionaries, plus a non-null nullable-union round trip, passed in both sync and async checks. Consider using a non-null |

Summary
Add 18 GET/PUT Spector contracts for discriminated unions with explicit
union extendsmodel constraints and nominally inherited alternatives.union-extends, while preserving existing validation imports and emitter/linter behavior. Surface configuration diagnostics and add virtual-filesystem regression tests.These scenarios define wire contracts, not language-specific SDK representations. Envelope scenarios are deferred.
Related: Azure/typespec-azure#5703.
Validation
pnpm -r --filter "@typespec/http-specs..." build.pnpm format,pnpm lint, documentation regeneration, andgit diff --checkpassed.The full
pnpm buildis blocked by an unrelatedtypespec-vsNuGet restore failure (NU1301, TLS handshake failure contactingapi.nuget.org).