Skip to content

Commit

Permalink
Linter tool document update: add R4004, modify R2016 ,R3006 (Azure#8417)
Browse files Browse the repository at this point in the history
* Linter tool document update: add R4004.

* Update linter doc :  modify R2016 ,R3006

* change date format

* Update  description of R2016
  • Loading branch information
jianyexi authored and microsoft-rin committed Feb 27, 2020
1 parent 076c77e commit ef43fa2
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion documentation/openapi-authoring-automated-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| [R2057](#r2057) | [InvalidSkuModel](#r2057) | ARM OpenAPI(swagger) specs |
| [R3010](#r3010) | [TrackedResourceListByImmediateParent](#r3010) | ARM OpenAPI(swagger) specs |
| [R2004](#r2004) | [NonApplicationJsonType](#r2004) | ARM OpenAPI(swagger) specs |
| [R4004](#r4004) | [OperationIdRequired](#r4004) | ARM OpenAPI(swagger) specs |
| [R3020](#r3020) | [PathResourceProviderNamePascalCase](#r3020) | ARM OpenAPI(swagger) specs |
| [R3021](#r3021) | [PathResouceTypeNameCamelCase](#r3021) | ARM OpenAPI(swagger) specs |
| [R3015](#r3015) | [EnumMustHaveType](#r3015) | ARM OpenAPI(swagger) specs |
Expand Down Expand Up @@ -1408,10 +1409,14 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul

**Applies to** : ARM OpenAPI(swagger) specs

**Output Message**: Top level properties should be one of name, type, id, location, properties, tags, plan, sku, etag, managedBy, identity. Model definition '{0}' has extra properties ['{1}'].
**Output Message**: Top level properties should be one of name, type, id, location, properties, tags, plan, sku, etag, managedBy, identity, systemdata. Model definition '{0}' has extra properties ['{1}'].

**Description**: Per [ARM guidelines](https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md), top level properties of a resource should be only ones from the allowed set.

**CreatedAt** : N/A

**LastModifiedAt** : February 18, 2020

**Why the rule is important**: [ARM guidelines](https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md).

**How to fix the violation**: Consider moving extra properties into "properties" bag of the resource model.
Expand Down Expand Up @@ -1662,11 +1667,56 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul
**Output Message**: Properties of a PATCH request body must not be {0}. PATCH operation: '{1}' Model Definition: '{2}' Property: '{3}'

**Description**: A request parameter of the Patch Operation must not have a required/default value.
But it's allowed when all required properties are marked as discriminator, because the discriminator must be required.

**CreatedAt** : N/A

**LastModifiedAt** : February 18, 2020

**Why the rule is important**: A PATCH operation is used to update properties of a resource. So, If the resource has 'X' number of properties and if you wish to change one of them, then a PATCH request could be sent with a value for that specified property. In other words, all the properties in the PATCH request are updated. Now, if any of the values are marked as required/default, it would force the system to update it always which is not the intention of the PATCH operation.

**How to fix the violation**: Ensure that the request parameter of the Patch Operation does not have a required/default value.

**Good Examples**: The following is a good example:
```json
......
......
"patch": {
"tags": [
"SampleTag"
],
"operationId": "Foo_Update",
"description": "Test Description",
"parameters": [
{
"name": "foo_patch",
"in": "body",
"schema": {
"$ref": "#/definitions/FooRequestParams"
},
"description": "foo patch request"
}
]
}
......
......
"definitions": {
"FooRequestParams": {
"properties": {
"prop0": {
"type": "string"
}
},
"discriminator": "prop0",
"required": [
"prop0"
]
}
}
......
......
```

Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rules](#automated-rules) | [ARM](#arm-violations): [Errors](#arm-errors) or [Warnings](#arm-warnings) | [SDK](#sdk-violations): [Errors](#sdk-errors) or [Warnings](#sdk-warnings)

### <a name="r4000" />R4000 ParameterDescriptionRequired
Expand Down Expand Up @@ -1846,6 +1896,24 @@ or
Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rules](#automated-rules) | [ARM](#arm-violations): [Errors](#arm-errors) or [Warnings](#arm-warnings) | [SDK](#sdk-violations): [Errors](#sdk-errors) or [Warnings](#sdk-warnings)


### <a name="r4004" ></a>R4004 OperationIdRequired

**Category** : ARM Warning

**Applies to** : ARM OpenAPI(swagger) specs

**Output Message** : Missing operationId. path:'${operation path}' operation:'${operation}'.

**Description** : Each operation must has a unique operationId.

**CreatedAt** : February 18, 2020

**LastModifiedAt** : February 18, 2020

**Why this rule is important**: Per [creating-swagger](creating-swagger.md#Paths),The operationId is used to determine the generated method name.

**How to fix the violation**: Add the right operationId for each operation

### <a name="r3020" ></a>R3020 PathResourceProviderNamePascalCase

**Category** : ARM Warning
Expand Down

0 comments on commit ef43fa2

Please sign in to comment.