From fee52de8d10e20e3d8e69e2f2e64ccda100d63de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 06:36:36 +0000 Subject: [PATCH 1/7] Initial plan From 70385c9717bfe7a8d7d56d4131e0b360dc8f5d55 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 06:46:21 +0000 Subject: [PATCH 2/7] feat: add spector case for extensible enum with special word member names Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 198 +++++++++ .../http-specs/specs/special-words/dec.js | 16 + .../http-specs/specs/special-words/main.tsp | 410 ++++++++++++++++++ .../http-specs/specs/special-words/mockapi.ts | 113 +++++ 4 files changed, 737 insertions(+) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index 418dbf7eafa..dbd7ce997c7 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -3977,6 +3977,204 @@ Expected header parameters: Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. +### SpecialWords_Enums_and + +- Endpoint: `get /special-words/enums/string/and` + +Verify that the enum member name "and" works. Mock api will return "and". + +### SpecialWords_Enums_as + +- Endpoint: `get /special-words/enums/string/as` + +Verify that the enum member name "as" works. Mock api will return "as". + +### SpecialWords_Enums_assert + +- Endpoint: `get /special-words/enums/string/assert` + +Verify that the enum member name "assert" works. Mock api will return "assert". + +### SpecialWords_Enums_async + +- Endpoint: `get /special-words/enums/string/async` + +Verify that the enum member name "async" works. Mock api will return "async". + +### SpecialWords_Enums_await + +- Endpoint: `get /special-words/enums/string/await` + +Verify that the enum member name "await" works. Mock api will return "await". + +### SpecialWords_Enums_break + +- Endpoint: `get /special-words/enums/string/break` + +Verify that the enum member name "break" works. Mock api will return "break". + +### SpecialWords_Enums_class + +- Endpoint: `get /special-words/enums/string/class` + +Verify that the enum member name "class" works. Mock api will return "class". + +### SpecialWords_Enums_constructor + +- Endpoint: `get /special-words/enums/string/constructor` + +Verify that the enum member name "constructor" works. Mock api will return "constructor". + +### SpecialWords_Enums_continue + +- Endpoint: `get /special-words/enums/string/continue` + +Verify that the enum member name "continue" works. Mock api will return "continue". + +### SpecialWords_Enums_def + +- Endpoint: `get /special-words/enums/string/def` + +Verify that the enum member name "def" works. Mock api will return "def". + +### SpecialWords_Enums_del + +- Endpoint: `get /special-words/enums/string/del` + +Verify that the enum member name "del" works. Mock api will return "del". + +### SpecialWords_Enums_elif + +- Endpoint: `get /special-words/enums/string/elif` + +Verify that the enum member name "elif" works. Mock api will return "elif". + +### SpecialWords_Enums_else + +- Endpoint: `get /special-words/enums/string/else` + +Verify that the enum member name "else" works. Mock api will return "else". + +### SpecialWords_Enums_except + +- Endpoint: `get /special-words/enums/string/except` + +Verify that the enum member name "except" works. Mock api will return "except". + +### SpecialWords_Enums_exec + +- Endpoint: `get /special-words/enums/string/exec` + +Verify that the enum member name "exec" works. Mock api will return "exec". + +### SpecialWords_Enums_finally + +- Endpoint: `get /special-words/enums/string/finally` + +Verify that the enum member name "finally" works. Mock api will return "finally". + +### SpecialWords_Enums_for + +- Endpoint: `get /special-words/enums/string/for` + +Verify that the enum member name "for" works. Mock api will return "for". + +### SpecialWords_Enums_from + +- Endpoint: `get /special-words/enums/string/from` + +Verify that the enum member name "from" works. Mock api will return "from". + +### SpecialWords_Enums_global + +- Endpoint: `get /special-words/enums/string/global` + +Verify that the enum member name "global" works. Mock api will return "global". + +### SpecialWords_Enums_if + +- Endpoint: `get /special-words/enums/string/if` + +Verify that the enum member name "if" works. Mock api will return "if". + +### SpecialWords_Enums_import + +- Endpoint: `get /special-words/enums/string/import` + +Verify that the enum member name "import" works. Mock api will return "import". + +### SpecialWords_Enums_in + +- Endpoint: `get /special-words/enums/string/in` + +Verify that the enum member name "in" works. Mock api will return "in". + +### SpecialWords_Enums_is + +- Endpoint: `get /special-words/enums/string/is` + +Verify that the enum member name "is" works. Mock api will return "is". + +### SpecialWords_Enums_lambda + +- Endpoint: `get /special-words/enums/string/lambda` + +Verify that the enum member name "lambda" works. Mock api will return "lambda". + +### SpecialWords_Enums_not + +- Endpoint: `get /special-words/enums/string/not` + +Verify that the enum member name "not" works. Mock api will return "not". + +### SpecialWords_Enums_or + +- Endpoint: `get /special-words/enums/string/or` + +Verify that the enum member name "or" works. Mock api will return "or". + +### SpecialWords_Enums_pass + +- Endpoint: `get /special-words/enums/string/pass` + +Verify that the enum member name "pass" works. Mock api will return "pass". + +### SpecialWords_Enums_raise + +- Endpoint: `get /special-words/enums/string/raise` + +Verify that the enum member name "raise" works. Mock api will return "raise". + +### SpecialWords_Enums_return + +- Endpoint: `get /special-words/enums/string/return` + +Verify that the enum member name "return" works. Mock api will return "return". + +### SpecialWords_Enums_try + +- Endpoint: `get /special-words/enums/string/try` + +Verify that the enum member name "try" works. Mock api will return "try". + +### SpecialWords_Enums_while + +- Endpoint: `get /special-words/enums/string/while` + +Verify that the enum member name "while" works. Mock api will return "while". + +### SpecialWords_Enums_with + +- Endpoint: `get /special-words/enums/string/with` + +Verify that the enum member name "with" works. Mock api will return "with". + +### SpecialWords_Enums_yield + +- Endpoint: `get /special-words/enums/string/yield` + +Verify that the enum member name "yield" works. Mock api will return "yield". + ### SpecialWords_ModelProperties_dictMethods - Endpoint: `get /special-words/model-properties/dict-methods` diff --git a/packages/http-specs/specs/special-words/dec.js b/packages/http-specs/specs/special-words/dec.js index b3188c2b223..4f2bcb2e705 100644 --- a/packages/http-specs/specs/special-words/dec.js +++ b/packages/http-specs/specs/special-words/dec.js @@ -50,3 +50,19 @@ export function $modelNameScenario(context, target, name) { ); context.call($route, target, `/${name.value}`); } + +/** + * + * @param {*} context + * @param {*} target + * @param {*} name + */ +export function $enumMemberNameScenario(context, target, name) { + context.call($scenario, target, name.value); + context.call( + $scenarioDoc, + target, + `Verify that the enum member name "${name.value}" works. Mock api will return "${name.value}".`, + ); + context.call($route, target, `/${name.value}`); +} diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index a48f1a3f257..3f9500823ef 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -289,3 +289,413 @@ namespace ModelProperties { @route("list") op withList(@body body: ModelWithList): void; } + +/** + * Verify enum member names that are special words using extensible enum (union). + */ +@doc("Extensible enum with special word members") +union Enum { + string, + + @doc("and.") + and: "and", + + @doc("as.") + as: "as", + + @doc("assert.") + assert: "assert", + + @doc("async.") + async: "async", + + @doc("await.") + await: "await", + + @doc("break.") + break: "break", + + @doc("class.") + class: "class", + + @doc("constructor.") + constructor: "constructor", + + @doc("continue.") + continue: "continue", + + @doc("def.") + def: "def", + + @doc("del.") + del: "del", + + @doc("elif.") + elif: "elif", + + @doc("else.") + `else`: "else", + + @doc("except.") + except: "except", + + @doc("exec.") + exec: "exec", + + @doc("finally.") + finally: "finally", + + @doc("for.") + for: "for", + + @doc("from.") + from: "from", + + @doc("global.") + global: "global", + + @doc("if.") + `if`: "if", + + @doc("import.") + `import`: "import", + + @doc("in.") + in: "in", + + @doc("is.") + `is`: "is", + + @doc("lambda.") + lambda: "lambda", + + @doc("not.") + not: "not", + + @doc("or.") + or: "or", + + @doc("pass.") + pass: "pass", + + @doc("raise.") + raise: "raise", + + @doc("return.") + `return`: "return", + + @doc("try.") + try: "try", + + @doc("while.") + while: "while", + + @doc("with.") + with: "with", + + @doc("yield.") + yield: "yield", +} + +/** + * Verify enum member names that are special words. + */ +@route("/enums/string") +interface Enums { + @enumMemberNameScenario("and") + @get + getAnd(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("as") + @get + getAs(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("assert") + @get + getAssert(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("async") + @get + getAsync(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("await") + @get + getAwait(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("break") + @get + getBreak(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("class") + @get + getClass(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("constructor") + @get + getConstructor(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("continue") + @get + getContinue(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("def") + @get + getDef(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("del") + @get + getDel(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("elif") + @get + getElif(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("else") + @get + getElse(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("except") + @get + getExcept(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("exec") + @get + getExec(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("finally") + @get + getFinally(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("for") + @get + getFor(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("from") + @get + getFrom(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("global") + @get + getGlobal(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("if") + @get + getIf(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("import") + @get + getImport(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("in") + @get + getIn(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("is") + @get + getIs(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("lambda") + @get + getLambda(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("not") + @get + getNot(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("or") + @get + getOr(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("pass") + @get + getPass(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("raise") + @get + getRaise(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("return") + @get + getReturn(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("try") + @get + getTry(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("while") + @get + getWhile(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("with") + @get + getWith(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; + + @enumMemberNameScenario("yield") + @get + getYield(): { + @header + contentType: "application/json"; + + @body body: Enum; + }; +} diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index 8076c8b7d4c..8d125097861 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -419,3 +419,116 @@ Scenarios.SpecialWords_Parameters_cancellationToken = createParametersTests( }, "cancellationToken", ); + +function createEnumServerTests(uri: string, data: string) { + return passOnSuccess({ + uri, + method: "get", + request: {}, + response: { + status: 200, + body: json(data), + }, + kind: "MockApiDefinition", + }); +} + +Scenarios.SpecialWords_Enums_and = createEnumServerTests(`/special-words/enums/string/and`, "and"); +Scenarios.SpecialWords_Enums_as = createEnumServerTests(`/special-words/enums/string/as`, "as"); +Scenarios.SpecialWords_Enums_assert = createEnumServerTests( + `/special-words/enums/string/assert`, + "assert", +); +Scenarios.SpecialWords_Enums_async = createEnumServerTests( + `/special-words/enums/string/async`, + "async", +); +Scenarios.SpecialWords_Enums_await = createEnumServerTests( + `/special-words/enums/string/await`, + "await", +); +Scenarios.SpecialWords_Enums_break = createEnumServerTests( + `/special-words/enums/string/break`, + "break", +); +Scenarios.SpecialWords_Enums_class = createEnumServerTests( + `/special-words/enums/string/class`, + "class", +); +Scenarios.SpecialWords_Enums_constructor = createEnumServerTests( + `/special-words/enums/string/constructor`, + "constructor", +); +Scenarios.SpecialWords_Enums_continue = createEnumServerTests( + `/special-words/enums/string/continue`, + "continue", +); +Scenarios.SpecialWords_Enums_def = createEnumServerTests(`/special-words/enums/string/def`, "def"); +Scenarios.SpecialWords_Enums_del = createEnumServerTests(`/special-words/enums/string/del`, "del"); +Scenarios.SpecialWords_Enums_elif = createEnumServerTests( + `/special-words/enums/string/elif`, + "elif", +); +Scenarios.SpecialWords_Enums_else = createEnumServerTests( + `/special-words/enums/string/else`, + "else", +); +Scenarios.SpecialWords_Enums_except = createEnumServerTests( + `/special-words/enums/string/except`, + "except", +); +Scenarios.SpecialWords_Enums_exec = createEnumServerTests( + `/special-words/enums/string/exec`, + "exec", +); +Scenarios.SpecialWords_Enums_finally = createEnumServerTests( + `/special-words/enums/string/finally`, + "finally", +); +Scenarios.SpecialWords_Enums_for = createEnumServerTests(`/special-words/enums/string/for`, "for"); +Scenarios.SpecialWords_Enums_from = createEnumServerTests( + `/special-words/enums/string/from`, + "from", +); +Scenarios.SpecialWords_Enums_global = createEnumServerTests( + `/special-words/enums/string/global`, + "global", +); +Scenarios.SpecialWords_Enums_if = createEnumServerTests(`/special-words/enums/string/if`, "if"); +Scenarios.SpecialWords_Enums_import = createEnumServerTests( + `/special-words/enums/string/import`, + "import", +); +Scenarios.SpecialWords_Enums_in = createEnumServerTests(`/special-words/enums/string/in`, "in"); +Scenarios.SpecialWords_Enums_is = createEnumServerTests(`/special-words/enums/string/is`, "is"); +Scenarios.SpecialWords_Enums_lambda = createEnumServerTests( + `/special-words/enums/string/lambda`, + "lambda", +); +Scenarios.SpecialWords_Enums_not = createEnumServerTests(`/special-words/enums/string/not`, "not"); +Scenarios.SpecialWords_Enums_or = createEnumServerTests(`/special-words/enums/string/or`, "or"); +Scenarios.SpecialWords_Enums_pass = createEnumServerTests( + `/special-words/enums/string/pass`, + "pass", +); +Scenarios.SpecialWords_Enums_raise = createEnumServerTests( + `/special-words/enums/string/raise`, + "raise", +); +Scenarios.SpecialWords_Enums_return = createEnumServerTests( + `/special-words/enums/string/return`, + "return", +); +Scenarios.SpecialWords_Enums_try = createEnumServerTests(`/special-words/enums/string/try`, "try"); +Scenarios.SpecialWords_Enums_while = createEnumServerTests( + `/special-words/enums/string/while`, + "while", +); +Scenarios.SpecialWords_Enums_with = createEnumServerTests( + `/special-words/enums/string/with`, + "with", +); +Scenarios.SpecialWords_Enums_yield = createEnumServerTests( + `/special-words/enums/string/yield`, + "yield", +); From ea7496eccaee5ac446e938263fe129138c162417 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 07:10:41 +0000 Subject: [PATCH 3/7] refactor: simplify to single PUT operation per review feedback Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 199 +----------- .../http-specs/specs/special-words/dec.js | 16 - .../http-specs/specs/special-words/main.tsp | 307 +----------------- .../http-specs/specs/special-words/mockapi.ts | 124 +------ 4 files changed, 29 insertions(+), 617 deletions(-) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index dbd7ce997c7..421ba496b02 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -3977,203 +3977,12 @@ Expected header parameters: Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. -### SpecialWords_Enums_and +### SpecialWords_Enums_putEnumValue -- Endpoint: `get /special-words/enums/string/and` +- Endpoint: `put /special-words/enums/string` -Verify that the enum member name "and" works. Mock api will return "and". - -### SpecialWords_Enums_as - -- Endpoint: `get /special-words/enums/string/as` - -Verify that the enum member name "as" works. Mock api will return "as". - -### SpecialWords_Enums_assert - -- Endpoint: `get /special-words/enums/string/assert` - -Verify that the enum member name "assert" works. Mock api will return "assert". - -### SpecialWords_Enums_async - -- Endpoint: `get /special-words/enums/string/async` - -Verify that the enum member name "async" works. Mock api will return "async". - -### SpecialWords_Enums_await - -- Endpoint: `get /special-words/enums/string/await` - -Verify that the enum member name "await" works. Mock api will return "await". - -### SpecialWords_Enums_break - -- Endpoint: `get /special-words/enums/string/break` - -Verify that the enum member name "break" works. Mock api will return "break". - -### SpecialWords_Enums_class - -- Endpoint: `get /special-words/enums/string/class` - -Verify that the enum member name "class" works. Mock api will return "class". - -### SpecialWords_Enums_constructor - -- Endpoint: `get /special-words/enums/string/constructor` - -Verify that the enum member name "constructor" works. Mock api will return "constructor". - -### SpecialWords_Enums_continue - -- Endpoint: `get /special-words/enums/string/continue` - -Verify that the enum member name "continue" works. Mock api will return "continue". - -### SpecialWords_Enums_def - -- Endpoint: `get /special-words/enums/string/def` - -Verify that the enum member name "def" works. Mock api will return "def". - -### SpecialWords_Enums_del - -- Endpoint: `get /special-words/enums/string/del` - -Verify that the enum member name "del" works. Mock api will return "del". - -### SpecialWords_Enums_elif - -- Endpoint: `get /special-words/enums/string/elif` - -Verify that the enum member name "elif" works. Mock api will return "elif". - -### SpecialWords_Enums_else - -- Endpoint: `get /special-words/enums/string/else` - -Verify that the enum member name "else" works. Mock api will return "else". - -### SpecialWords_Enums_except - -- Endpoint: `get /special-words/enums/string/except` - -Verify that the enum member name "except" works. Mock api will return "except". - -### SpecialWords_Enums_exec - -- Endpoint: `get /special-words/enums/string/exec` - -Verify that the enum member name "exec" works. Mock api will return "exec". - -### SpecialWords_Enums_finally - -- Endpoint: `get /special-words/enums/string/finally` - -Verify that the enum member name "finally" works. Mock api will return "finally". - -### SpecialWords_Enums_for - -- Endpoint: `get /special-words/enums/string/for` - -Verify that the enum member name "for" works. Mock api will return "for". - -### SpecialWords_Enums_from - -- Endpoint: `get /special-words/enums/string/from` - -Verify that the enum member name "from" works. Mock api will return "from". - -### SpecialWords_Enums_global - -- Endpoint: `get /special-words/enums/string/global` - -Verify that the enum member name "global" works. Mock api will return "global". - -### SpecialWords_Enums_if - -- Endpoint: `get /special-words/enums/string/if` - -Verify that the enum member name "if" works. Mock api will return "if". - -### SpecialWords_Enums_import - -- Endpoint: `get /special-words/enums/string/import` - -Verify that the enum member name "import" works. Mock api will return "import". - -### SpecialWords_Enums_in - -- Endpoint: `get /special-words/enums/string/in` - -Verify that the enum member name "in" works. Mock api will return "in". - -### SpecialWords_Enums_is - -- Endpoint: `get /special-words/enums/string/is` - -Verify that the enum member name "is" works. Mock api will return "is". - -### SpecialWords_Enums_lambda - -- Endpoint: `get /special-words/enums/string/lambda` - -Verify that the enum member name "lambda" works. Mock api will return "lambda". - -### SpecialWords_Enums_not - -- Endpoint: `get /special-words/enums/string/not` - -Verify that the enum member name "not" works. Mock api will return "not". - -### SpecialWords_Enums_or - -- Endpoint: `get /special-words/enums/string/or` - -Verify that the enum member name "or" works. Mock api will return "or". - -### SpecialWords_Enums_pass - -- Endpoint: `get /special-words/enums/string/pass` - -Verify that the enum member name "pass" works. Mock api will return "pass". - -### SpecialWords_Enums_raise - -- Endpoint: `get /special-words/enums/string/raise` - -Verify that the enum member name "raise" works. Mock api will return "raise". - -### SpecialWords_Enums_return - -- Endpoint: `get /special-words/enums/string/return` - -Verify that the enum member name "return" works. Mock api will return "return". - -### SpecialWords_Enums_try - -- Endpoint: `get /special-words/enums/string/try` - -Verify that the enum member name "try" works. Mock api will return "try". - -### SpecialWords_Enums_while - -- Endpoint: `get /special-words/enums/string/while` - -Verify that the enum member name "while" works. Mock api will return "while". - -### SpecialWords_Enums_with - -- Endpoint: `get /special-words/enums/string/with` - -Verify that the enum member name "with" works. Mock api will return "with". - -### SpecialWords_Enums_yield - -- Endpoint: `get /special-words/enums/string/yield` - -Verify that the enum member name "yield" works. Mock api will return "yield". +Verify that enum members with special word names can be sent and received properly. +Expect to send a known value. Mock api expect to receive 'class'. ### SpecialWords_ModelProperties_dictMethods diff --git a/packages/http-specs/specs/special-words/dec.js b/packages/http-specs/specs/special-words/dec.js index 4f2bcb2e705..b3188c2b223 100644 --- a/packages/http-specs/specs/special-words/dec.js +++ b/packages/http-specs/specs/special-words/dec.js @@ -50,19 +50,3 @@ export function $modelNameScenario(context, target, name) { ); context.call($route, target, `/${name.value}`); } - -/** - * - * @param {*} context - * @param {*} target - * @param {*} name - */ -export function $enumMemberNameScenario(context, target, name) { - context.call($scenario, target, name.value); - context.call( - $scenarioDoc, - target, - `Verify that the enum member name "${name.value}" works. Mock api will return "${name.value}".`, - ); - context.call($route, target, `/${name.value}`); -} diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index 3f9500823ef..720f6188d45 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -400,302 +400,19 @@ union Enum { /** * Verify enum member names that are special words. */ -@route("/enums/string") +@route("/enums") interface Enums { - @enumMemberNameScenario("and") - @get - getAnd(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("as") - @get - getAs(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("assert") - @get - getAssert(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("async") - @get - getAsync(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("await") - @get - getAwait(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("break") - @get - getBreak(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("class") - @get - getClass(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("constructor") - @get - getConstructor(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("continue") - @get - getContinue(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("def") - @get - getDef(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("del") - @get - getDel(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("elif") - @get - getElif(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("else") - @get - getElse(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("except") - @get - getExcept(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("exec") - @get - getExec(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("finally") - @get - getFinally(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("for") - @get - getFor(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("from") - @get - getFrom(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("global") - @get - getGlobal(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("if") - @get - getIf(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("import") - @get - getImport(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("in") - @get - getIn(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("is") - @get - getIs(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("lambda") - @get - getLambda(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("not") - @get - getNot(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("or") - @get - getOr(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("pass") - @get - getPass(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("raise") - @get - getRaise(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("return") - @get - getReturn(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("try") - @get - getTry(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("while") - @get - getWhile(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("with") - @get - getWith(): { - @header - contentType: "application/json"; - - @body body: Enum; - }; - - @enumMemberNameScenario("yield") - @get - getYield(): { + @scenario + @scenarioDoc(""" + Verify that enum members with special word names can be sent and received properly. + Expect to send a known value. Mock api expect to receive 'class'. + """) + @put + @route("/string") + putEnumValue( @header - contentType: "application/json"; + contentType: "application/json", - @body body: Enum; - }; + @body body: Enum, + ): void; } diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index 8d125097861..d2377959d7c 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -420,115 +420,17 @@ Scenarios.SpecialWords_Parameters_cancellationToken = createParametersTests( "cancellationToken", ); -function createEnumServerTests(uri: string, data: string) { - return passOnSuccess({ - uri, - method: "get", - request: {}, - response: { - status: 200, - body: json(data), +Scenarios.SpecialWords_Enums_putEnumValue = passOnSuccess({ + uri: `/special-words/enums/string`, + method: "put", + request: { + body: json("class"), + headers: { + "Content-Type": "text/plain", }, - kind: "MockApiDefinition", - }); -} - -Scenarios.SpecialWords_Enums_and = createEnumServerTests(`/special-words/enums/string/and`, "and"); -Scenarios.SpecialWords_Enums_as = createEnumServerTests(`/special-words/enums/string/as`, "as"); -Scenarios.SpecialWords_Enums_assert = createEnumServerTests( - `/special-words/enums/string/assert`, - "assert", -); -Scenarios.SpecialWords_Enums_async = createEnumServerTests( - `/special-words/enums/string/async`, - "async", -); -Scenarios.SpecialWords_Enums_await = createEnumServerTests( - `/special-words/enums/string/await`, - "await", -); -Scenarios.SpecialWords_Enums_break = createEnumServerTests( - `/special-words/enums/string/break`, - "break", -); -Scenarios.SpecialWords_Enums_class = createEnumServerTests( - `/special-words/enums/string/class`, - "class", -); -Scenarios.SpecialWords_Enums_constructor = createEnumServerTests( - `/special-words/enums/string/constructor`, - "constructor", -); -Scenarios.SpecialWords_Enums_continue = createEnumServerTests( - `/special-words/enums/string/continue`, - "continue", -); -Scenarios.SpecialWords_Enums_def = createEnumServerTests(`/special-words/enums/string/def`, "def"); -Scenarios.SpecialWords_Enums_del = createEnumServerTests(`/special-words/enums/string/del`, "del"); -Scenarios.SpecialWords_Enums_elif = createEnumServerTests( - `/special-words/enums/string/elif`, - "elif", -); -Scenarios.SpecialWords_Enums_else = createEnumServerTests( - `/special-words/enums/string/else`, - "else", -); -Scenarios.SpecialWords_Enums_except = createEnumServerTests( - `/special-words/enums/string/except`, - "except", -); -Scenarios.SpecialWords_Enums_exec = createEnumServerTests( - `/special-words/enums/string/exec`, - "exec", -); -Scenarios.SpecialWords_Enums_finally = createEnumServerTests( - `/special-words/enums/string/finally`, - "finally", -); -Scenarios.SpecialWords_Enums_for = createEnumServerTests(`/special-words/enums/string/for`, "for"); -Scenarios.SpecialWords_Enums_from = createEnumServerTests( - `/special-words/enums/string/from`, - "from", -); -Scenarios.SpecialWords_Enums_global = createEnumServerTests( - `/special-words/enums/string/global`, - "global", -); -Scenarios.SpecialWords_Enums_if = createEnumServerTests(`/special-words/enums/string/if`, "if"); -Scenarios.SpecialWords_Enums_import = createEnumServerTests( - `/special-words/enums/string/import`, - "import", -); -Scenarios.SpecialWords_Enums_in = createEnumServerTests(`/special-words/enums/string/in`, "in"); -Scenarios.SpecialWords_Enums_is = createEnumServerTests(`/special-words/enums/string/is`, "is"); -Scenarios.SpecialWords_Enums_lambda = createEnumServerTests( - `/special-words/enums/string/lambda`, - "lambda", -); -Scenarios.SpecialWords_Enums_not = createEnumServerTests(`/special-words/enums/string/not`, "not"); -Scenarios.SpecialWords_Enums_or = createEnumServerTests(`/special-words/enums/string/or`, "or"); -Scenarios.SpecialWords_Enums_pass = createEnumServerTests( - `/special-words/enums/string/pass`, - "pass", -); -Scenarios.SpecialWords_Enums_raise = createEnumServerTests( - `/special-words/enums/string/raise`, - "raise", -); -Scenarios.SpecialWords_Enums_return = createEnumServerTests( - `/special-words/enums/string/return`, - "return", -); -Scenarios.SpecialWords_Enums_try = createEnumServerTests(`/special-words/enums/string/try`, "try"); -Scenarios.SpecialWords_Enums_while = createEnumServerTests( - `/special-words/enums/string/while`, - "while", -); -Scenarios.SpecialWords_Enums_with = createEnumServerTests( - `/special-words/enums/string/with`, - "with", -); -Scenarios.SpecialWords_Enums_yield = createEnumServerTests( - `/special-words/enums/string/yield`, - "yield", -); + }, + response: { + status: 204, + }, + kind: "MockApiDefinition", +}); From 358075d794a9f3f884ed9227bfc8c282b463d9ae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 07:48:11 +0000 Subject: [PATCH 4/7] feat: add Enum return type to putEnumValue operation (echo pattern) Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-specs/spec-summary.md | 2 +- packages/http-specs/specs/special-words/main.tsp | 9 +++++++-- packages/http-specs/specs/special-words/mockapi.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/http-specs/spec-summary.md b/packages/http-specs/spec-summary.md index 421ba496b02..d058ef3fb5a 100644 --- a/packages/http-specs/spec-summary.md +++ b/packages/http-specs/spec-summary.md @@ -3982,7 +3982,7 @@ Check we recognize Repeatability-Request-ID and Repeatability-First-Sent. - Endpoint: `put /special-words/enums/string` Verify that enum members with special word names can be sent and received properly. -Expect to send a known value. Mock api expect to receive 'class'. +Send 'class' and expect the same value back. ### SpecialWords_ModelProperties_dictMethods diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index 720f6188d45..7140185d920 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -405,7 +405,7 @@ interface Enums { @scenario @scenarioDoc(""" Verify that enum members with special word names can be sent and received properly. - Expect to send a known value. Mock api expect to receive 'class'. + Send 'class' and expect the same value back. """) @put @route("/string") @@ -414,5 +414,10 @@ interface Enums { contentType: "application/json", @body body: Enum, - ): void; + ): { + @header + contentType: "application/json"; + + @body body: Enum; + }; } diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index d2377959d7c..775f2af6723 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -430,7 +430,8 @@ Scenarios.SpecialWords_Enums_putEnumValue = passOnSuccess({ }, }, response: { - status: 204, + status: 200, + body: json("class"), }, kind: "MockApiDefinition", }); From b843a228e215556ee1e3fd257c1bf31baa16c384 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:30:57 +0000 Subject: [PATCH 5/7] fix: echo request body dynamically in mock API handler Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-specs/specs/special-words/mockapi.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index 775f2af6723..2e9799246f1 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -1,4 +1,4 @@ -import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; +import { json, MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; export const Scenarios: Record = {}; @@ -433,5 +433,11 @@ Scenarios.SpecialWords_Enums_putEnumValue = passOnSuccess({ status: 200, body: json("class"), }, + handler: (req: MockRequest) => { + return { + status: 200, + body: json(req.body), + }; + }, kind: "MockApiDefinition", }); From 2434f48b647eb02d7dcdf4ce9b95e22e1986d656 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:35:10 +0000 Subject: [PATCH 6/7] refactor: remove explicit contentType headers, use default application/json Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-specs/specs/special-words/main.tsp | 10 +--------- packages/http-specs/specs/special-words/mockapi.ts | 3 --- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index 7140185d920..2cdb161688c 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -409,15 +409,7 @@ interface Enums { """) @put @route("/string") - putEnumValue( - @header - contentType: "application/json", - - @body body: Enum, - ): { - @header - contentType: "application/json"; - + putEnumValue(@body body: Enum): { @body body: Enum; }; } diff --git a/packages/http-specs/specs/special-words/mockapi.ts b/packages/http-specs/specs/special-words/mockapi.ts index 2e9799246f1..cd8389f7ff1 100644 --- a/packages/http-specs/specs/special-words/mockapi.ts +++ b/packages/http-specs/specs/special-words/mockapi.ts @@ -425,9 +425,6 @@ Scenarios.SpecialWords_Enums_putEnumValue = passOnSuccess({ method: "put", request: { body: json("class"), - headers: { - "Content-Type": "text/plain", - }, }, response: { status: 200, From f70bb685093fbba0073f80433840b04e534e1544 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:50:04 +0000 Subject: [PATCH 7/7] refactor: remove redundant @doc decorators from union for consistency Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../http-specs/specs/special-words/main.tsp | 67 ------------------- 1 file changed, 67 deletions(-) diff --git a/packages/http-specs/specs/special-words/main.tsp b/packages/http-specs/specs/special-words/main.tsp index 2cdb161688c..df03b05e4b2 100644 --- a/packages/http-specs/specs/special-words/main.tsp +++ b/packages/http-specs/specs/special-words/main.tsp @@ -293,107 +293,40 @@ namespace ModelProperties { /** * Verify enum member names that are special words using extensible enum (union). */ -@doc("Extensible enum with special word members") union Enum { string, - - @doc("and.") and: "and", - - @doc("as.") as: "as", - - @doc("assert.") assert: "assert", - - @doc("async.") async: "async", - - @doc("await.") await: "await", - - @doc("break.") break: "break", - - @doc("class.") class: "class", - - @doc("constructor.") constructor: "constructor", - - @doc("continue.") continue: "continue", - - @doc("def.") def: "def", - - @doc("del.") del: "del", - - @doc("elif.") elif: "elif", - - @doc("else.") `else`: "else", - - @doc("except.") except: "except", - - @doc("exec.") exec: "exec", - - @doc("finally.") finally: "finally", - - @doc("for.") for: "for", - - @doc("from.") from: "from", - - @doc("global.") global: "global", - - @doc("if.") `if`: "if", - - @doc("import.") `import`: "import", - - @doc("in.") in: "in", - - @doc("is.") `is`: "is", - - @doc("lambda.") lambda: "lambda", - - @doc("not.") not: "not", - - @doc("or.") or: "or", - - @doc("pass.") pass: "pass", - - @doc("raise.") raise: "raise", - - @doc("return.") `return`: "return", - - @doc("try.") try: "try", - - @doc("while.") while: "while", - - @doc("with.") with: "with", - - @doc("yield.") yield: "yield", }