Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-specs"
---

Add test case for model property named "list" to cover special word scenarios
12 changes: 12 additions & 0 deletions packages/http-specs/spec-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -3517,6 +3517,18 @@ Send
{ "SameAsModel": "ok" }
```

### SpecialWords_ModelProperties_withList

- Endpoint: `get /special-words/model-properties/list`

Verify that a property can be named "list", which is a reserved word in many languages like Python.

Send

```json
{ "list": "ok" }
```

### SpecialWords_Models_and

- Endpoint: `get /special-words/models/and`
Expand Down
19 changes: 19 additions & 0 deletions packages/http-specs/specs/special-words/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using Spector;
* in
* is
* lambda
* list
* not
* or
* pass
Expand Down Expand Up @@ -269,4 +270,22 @@ namespace ModelProperties {
""")
@route("dict-methods")
op dictMethods(@body body: DictMethods): void;

// Test for model property named "list" which is a reserved word in many languages
model ModelWithList {
list: string;
}

@scenario
@scenarioDoc("""
Verify that a property can be named "list", which is a reserved word in many languages like Python.

Send

```json
{"list": "ok"}
```
""")
@route("list")
op withList(@body body: ModelWithList): void;
}
14 changes: 14 additions & 0 deletions packages/http-specs/specs/special-words/mockapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ Scenarios.SpecialWords_ModelProperties_dictMethods = passOnSuccess({
kind: "MockApiDefinition",
});

Scenarios.SpecialWords_ModelProperties_withList = passOnSuccess({
uri: "/special-words/model-properties/list",
method: "post",
request: {
body: json({
list: "ok",
}),
},
response: {
status: 204,
},
kind: "MockApiDefinition",
});

function createModelsTests(uri: string) {
return passOnSuccess({
uri,
Expand Down
Loading