Skip to content

Commit a954384

Browse files
AkhilaIllaakhilailla
andauthored
Add QueryParametersInCollectionGet linter rule (#745)
* Add QueryParametersInCollectionGet linter rule * Update logic to figure out list op paths * Add staging only * Address comments --------- Co-authored-by: akhilailla <[email protected]>
1 parent a19b89c commit a954384

File tree

9 files changed

+725
-148
lines changed

9 files changed

+725
-148
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# QueryParametersInCollectionGet
2+
3+
## Category
4+
5+
ARM Error
6+
7+
## Applies to
8+
9+
ARM OpenAPI(swagger) specs
10+
11+
## Related ARM Guideline Code
12+
13+
- RPC-Get-V1-15
14+
15+
## Description
16+
17+
Collection Get's/List operations MUST not have query parameters other than api-version & OData filter.
18+
19+
## How to fix the violation
20+
21+
Ensure that collection GET/List operations do not include any query parameters other than api-version and the OData $filter.
22+
23+
## Good Examples
24+
25+
```json
26+
"Microsoft.Music/Songs": {
27+
"get": {
28+
"operationId": "Foo_Update",
29+
"description": "Test Description",
30+
"parameters": [
31+
{
32+
"name": "api-version",
33+
"in": "query"
34+
},
35+
],
36+
},
37+
},
38+
```
39+
40+
```json
41+
"Microsoft.Music/Songs": {
42+
"get": {
43+
"operationId": "Foo_Update",
44+
"description": "Test Description",
45+
"parameters": [
46+
{
47+
"name": "api-version",
48+
"in": "query"
49+
},
50+
{
51+
"name": "$filter",
52+
"in": "query",
53+
"required": false,
54+
"type": "string",
55+
},
56+
],
57+
},
58+
},
59+
```
60+
61+
## Bad Examples
62+
63+
```json
64+
"Microsoft.Music/Songs": {
65+
"get": {
66+
"operationId": "Foo_Update",
67+
"description": "Test Description",
68+
"parameters": [
69+
{
70+
"name": "name",
71+
"in": "query",
72+
"required": false,
73+
"type": "string",
74+
},
75+
],
76+
},
77+
},
78+
```

docs/rules.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,12 @@ Synchronous and long-running PUT operations must have responses with 200, 201 an
10401040

10411041
Please refer to [put-response-codes.md](./put-response-codes.md) for details.
10421042

1043+
### QueryParametersInCollectionGet
1044+
1045+
Collection Get's/List operations MUST not have query parameters other than api-version & OData filter.
1046+
1047+
Please refer to [query-parameters-in-collection-get.md](./query-parameters-in-collection-get.md) for details.
1048+
10431049
### RepeatedPathInfo
10441050

10451051
Information in the URI must not be repeated in the request body (i.e. subscription ID, resource group name, resource name).

0 commit comments

Comments
 (0)