-
Notifications
You must be signed in to change notification settings - Fork 283
[spector] Add discriminated union test cases #7602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
@copilot Apply comments #7602 (comment) and #7602 (comment) for all scenarios. |
… to all GET endpoints Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Applied both comments to all scenarios:
Updated mockapi implementations to handle the optional parameters with appropriate response logic (when parameter is null/"cat" returns cat response, when "dog" returns dog response). All 56 scenarios pass validation. Implemented in commit ab3ee92. |
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
… union scenarios Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
All changed packages have been documented.
Show changes
|
…ehavior Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@joheredi js 3p emitter e2e failure for this case blocks this pr, is it possible to prioritze the fix?
|
This appears to be an issue with the JS emitter's code generation for discriminated unions rather than with the TypeSpec definitions. I've verified that: ✅ All 56 scenarios pass TypeSpec validation The error shows that the generated TypeScript serializers are trying to assign This suggests the JS emitter needs updates to properly handle discriminated union serialization. The TypeSpec definitions follow the standard patterns from the documentation and work correctly at the TypeSpec level. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
- Reorganized into Envelope > Object > (Default, CustomProperties) and NoEnvelope structure - Updated routes: /envelope/object/default, /envelope/object/custom-properties, /no-envelope - Updated operation names and mockapi implementations to match new hierarchy - Provides better scalability for future envelope types as suggested Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
This PR adds comprehensive spector test cases for discriminated unions based on the TypeSpec standard library documentation.
Scenarios Implemented
Added test cases covering the three main discriminated union patterns:
Default serialization (
/envelope
) - Uses defaultkind
andvalue
envelope structure:Custom property names (
/custom-names
) - Uses custom discriminator and envelope properties:Inline discriminator (
/inline
) - Usesenvelope: "none"
to inject discriminator directly:Each scenario includes both GET and PUT operations with complete mockapi implementations.
Files Added
packages/http-specs/specs/type/union/discriminated/main.tsp
- TypeSpec definitions with 6 scenariospackages/http-specs/specs/type/union/discriminated/mockapi.ts
- Mock API implementationsspec-summary.md
with auto-generated documentationValidation
✅ All 56 scenarios (including new ones) pass validation
✅ TypeScript compilation successful
✅ Mock API validation passes
✅ No linting errors
✅ Documentation regenerated
The implementation follows existing spector patterns and provides comprehensive test coverage for discriminated unions as specified in the TypeSpec documentation.
Fixes #7601.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
typespec.io
curl -s REDACTED
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.