-
Notifications
You must be signed in to change notification settings - Fork 381
feat: add cross-language Spector tests for dollar-sign query params and discriminator without subtypes #10841
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
Changes from all commits
b40d857
33a2d33
036e75b
a180e1b
c630cef
724b131
ad40f3b
bc1d3ab
1efe1c9
42946e0
b32279f
8c7d940
b705846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@typespec/http-specs" | ||
| --- | ||
|
|
||
| add test for discriminator model without subtypes and query params with `$` prefixes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| # Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking | ||
| changeKind: internal | ||
| packages: | ||
| - "@typespec/http-client-js" | ||
| --- | ||
|
|
||
| skip some spector tests |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import "@typespec/http"; | ||
| import "@typespec/spector"; | ||
|
|
||
| using Http; | ||
| using Spector; | ||
|
|
||
| @doc("Test for @bodyRoot parameter patterns.") | ||
| @scenarioService("/parameters/body-root") | ||
| namespace Parameters.BodyRoot; | ||
|
|
||
| model BodyRootModel { | ||
| category?: string; | ||
| linkType?: string; | ||
| wasSuccessful?: boolean; | ||
| } | ||
|
|
||
| @scenario | ||
| @scenarioDoc(""" | ||
| Test case for a \`@bodyRoot\` parameter nested inside a wrapper model. | ||
|
|
||
| Emitters must resolve the accessor path through the wrapper (e.g. | ||
| \`body.bodyRootParameters\`) rather than referencing the property name | ||
| directly. | ||
|
|
||
| Expected request body: | ||
| \`\`\`json | ||
| { "category": "widget", "linkType": "hard", "wasSuccessful": true } | ||
| \`\`\` | ||
| """) | ||
| @route("/nested") | ||
| @post | ||
| op nested( | ||
| body: { | ||
| @bodyRoot bodyRootParameters: BodyRootModel; | ||
| }, | ||
|
iscai-msft marked this conversation as resolved.
|
||
| ): NoContentResponse; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; | ||
|
|
||
| export const Scenarios: Record<string, ScenarioMockApi> = {}; | ||
|
|
||
| Scenarios.Parameters_BodyRoot_nested = passOnSuccess({ | ||
| uri: "/parameters/body-root/nested", | ||
| method: "post", | ||
| request: { | ||
| body: json({ | ||
| category: "widget", | ||
| linkType: "hard", | ||
| wasSuccessful: true, | ||
| }), | ||
| }, | ||
| response: { | ||
| status: 204, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,15 @@ Scenarios.Parameters_Query_Constant_post = passOnSuccess({ | |
| }, | ||
| kind: "MockApiDefinition", | ||
| }); | ||
|
|
||
| Scenarios.Parameters_Query_SpecialChar_dollarSign = passOnSuccess({ | ||
| uri: "/parameters/query/special-char/dollar-sign", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This path doesn't match the route in the tsp.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC @iscai-msft
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like Copilot should have caught this but it didn't run.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to fix it in #10963 |
||
| method: "get", | ||
| request: { | ||
| query: { $filter: "status eq 'active'" }, | ||
| }, | ||
| response: { | ||
| status: 204, | ||
| }, | ||
| kind: "MockApiDefinition", | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.