Skip to content

Commit

Permalink
Add QueryParametersInCollectionGet linter rule (#745)
Browse files Browse the repository at this point in the history
* Add QueryParametersInCollectionGet linter rule

* Update logic to figure out list op paths

* Add staging only

* Address comments

---------

Co-authored-by: akhilailla <[email protected]>
  • Loading branch information
AkhilaIlla and akhilailla committed Sep 18, 2024
1 parent a19b89c commit a954384
Show file tree
Hide file tree
Showing 9 changed files with 725 additions and 148 deletions.
78 changes: 78 additions & 0 deletions docs/query-parameters-in-collection-get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# QueryParametersInCollectionGet

## Category

ARM Error

## Applies to

ARM OpenAPI(swagger) specs

## Related ARM Guideline Code

- RPC-Get-V1-15

## Description

Collection Get's/List operations MUST not have query parameters other than api-version & OData filter.

## How to fix the violation

Ensure that collection GET/List operations do not include any query parameters other than api-version and the OData $filter.

## Good Examples

```json
"Microsoft.Music/Songs": {
"get": {
"operationId": "Foo_Update",
"description": "Test Description",
"parameters": [
{
"name": "api-version",
"in": "query"
},
],
},
},
```

```json
"Microsoft.Music/Songs": {
"get": {
"operationId": "Foo_Update",
"description": "Test Description",
"parameters": [
{
"name": "api-version",
"in": "query"
},
{
"name": "$filter",
"in": "query",
"required": false,
"type": "string",
},
],
},
},
```

## Bad Examples

```json
"Microsoft.Music/Songs": {
"get": {
"operationId": "Foo_Update",
"description": "Test Description",
"parameters": [
{
"name": "name",
"in": "query",
"required": false,
"type": "string",
},
],
},
},
```
6 changes: 6 additions & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,12 @@ Synchronous and long-running PUT operations must have responses with 200, 201 an

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

### QueryParametersInCollectionGet

Collection Get's/List operations MUST not have query parameters other than api-version & OData filter.

Please refer to [query-parameters-in-collection-get.md](./query-parameters-in-collection-get.md) for details.

### RepeatedPathInfo

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

0 comments on commit a954384

Please sign in to comment.