Skip to content
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

Add QueryParametersInCollectionGet linter rule #745

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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