Skip to content

Commit c9042da

Browse files
jianyexijianye xiTianxiang Chen
authored andcommitted
add new lint rules doc (Azure#16712)
* add two rules * add index * fix typo * add a new rule * update category * fix comments * fix comments Co-authored-by: jianye xi <[email protected]> Co-authored-by: Tianxiang Chen <[email protected]>
1 parent f17483d commit c9042da

File tree

1 file changed

+83
-4
lines changed

1 file changed

+83
-4
lines changed

documentation/openapi-authoring-automated-guidelines.md

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
100100
| [R2054](#r2054) | [SecurityDefinitionsStructure](#r2054) | ARM OpenAPI(swagger) specs |
101101
| [R2006](#r2006) | [ControlCharactersNotAllowed](#r2006) | ARM and Data plane OpenAPI(swagger) specs |
102102
| [R2009](#r2009) | [ArraySchemaMustHaveItems](#r2009) | ARM and Data plane OpenAPI(swagger) specs |
103+
| [R2018](#r2018) | [XmsEnumValidation](#r2018) | ARM and Data plane OpenAPI(swagger) specs |
103104
| [R3013](#r3013) | [DeleteMustNotHaveRequestBody](#r3013) | ARM and Data plane OpenAPI(swagger) specs |
104105
| [R4001](#r4001) | [XmsParameterLocation](#r4001) | ARM and Data plan OpenAPI(swagger) specs |
105106
| [R3015](#r3015) | [EnumMustHaveType](#r3015) | ARM and Data plan OpenAPI(swagger) specs |
@@ -109,14 +110,16 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
109110
| [R4008](#r4008) | [AvoidEmptyResponseSchema](#r4008) | ARM OpenAPI(swagger) specs |
110111
| [R4012](#r4012) | [XmsPageableMustHaveCorrespondingResponse](#r4012) | ARM OpenAPI(swagger) specs |
111112
| [R4013](#r4013) | [IntegerTypeMustHaveFormat](#r4013) | ARM OpenAPI(swagger) specs |
112-
| [R4028](#r4028) | [ValidResponseCodeRequired](#r4028) | ARM OpenAPI(swagger) specs |
113+
| [R4028](#r4028) | [ValidResponseCodeRequired](#r4028) | ARM and Data Plane OpenAPI(swagger) specs |
113114
| [R4029](#r4029) | [UniqueClientParameterName](#r4029) | ARM OpenAPI(swagger) specs |
114115
| [R4032](#r4032) | [MissingXmsErrorResponse](#r4032) | ARM OpenAPI(swagger) specs |
115116
| [R4033](#r4033) | [UniqueModelName](#r4033) | ARM OpenAPI(swagger) specs |
116117
| [R4034](#r4034) | [AzureResourceTagsSchemaValidation](#r4034) | ARM OpenAPI(swagger) specs |
117118
| [R4035](#r4035) | [PrivateEndpointResourceSchemaValidation](#r4035) | ARM OpenAPI(swagger) specs |
118119
| [R4036](#r4036) | [ImplementPrivateEndpointAPIs](#r4036) | ARM OpenAPI(swagger) specs |
119120
| [R4037](#r4037) | [MissingTypeObject](#r4037) | ARM and Data plan OpenAPI(swagger) specs |
121+
| [R4039](#r4039) | [ParametersOrder](#r4039) | ARM and Data plan OpenAPI(swagger) specs |
122+
| [R4040](#r4040) | [EnumMustRespectType](#r4040) | ARM and Data plan OpenAPI(swagger) specs |
120123
#### SDK Warnings
121124

122125
| Id | Rule Name | Applies to |
@@ -138,7 +141,6 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
138141
| [R1007](#r1007) | [PatchInOperationName](#r1007) | ARM and Data plane OpenAPI(swagger) specs |
139142
| [R1011](#r1011) | [HttpsSupportedScheme](#r1011) | ARM OpenAPI(swagger) specs |
140143
| [R2065](#r2065) | [LicenseHeaderMustNotBeSpecified](#r2065) | ARM and Data plane OpenAPI(swagger) specs |
141-
| [R2018](#r2018) | [XmsEnumValidation](#r2018) | ARM and Data plane OpenAPI(swagger) specs |
142144
| [R3060](#r3060) | [XmsPageableListByRGAndSubscriptions](#r3060) | ARM OpenAPI(swagger) specs |
143145
| [R2063](#r2063) | [OperationIdNounConflictingModelNames](#r2063) | ARM and Data plane OpenAPI(swagger) specs |
144146
| [R2064](#r2064) | [LROStatusCodesReturnTypeSchema](#r2064) | ARM and Data plane OpenAPI(swagger) specs |
@@ -161,6 +163,7 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
161163
| [R4025](#r4025) | [RPaasDeleteLongRunningOperation202Only](#r4025) | ARM OpenAPI(swagger) specs |
162164
| [R4026](#r4026) | [RPaasPostLongRunningOperation202Only](#r4026) | ARM OpenAPI(swagger) specs |
163165
| [R4031](#r4031) | [RPaasResourceProvisioningState](#r4031) | ARM OpenAPI(swagger) specs |
166+
| [R4038](#r4038) | [ExtensionResourcePathPattern](#r4038) | ARM OpenAPI(swagger) specs |
164167
### Documentation
165168

166169
#### Documentation Errors
@@ -1504,7 +1507,7 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul
15041507
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)
15051508

15061509
### <a name="r2018" />R2018 XmsEnumValidation
1507-
**Category** : SDK Warning
1510+
**Category** : SDK Error
15081511

15091512
**Applies to** : ARM and Data plane OpenAPI(swagger) specs
15101513

@@ -3107,7 +3110,7 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul
31073110

31083111
**Category** : SDK Error
31093112

3110-
**Applies to** : ARM OpenAPI(swagger) specs
3113+
**Applies to** : ARM and Data Plane OpenAPI(swagger) specs
31113114

31123115
**Output Message** : There is no declared valid status code.
31133116

@@ -3500,3 +3503,79 @@ The following would be invalid by default (unless you do it on purpose , then a
35003503
}
35013504
```
35023505
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)
3506+
3507+
3508+
### <a name="r4038"></a>R4038 ExtensionResourcePathPattern
3509+
3510+
**Category** : RPaaS Error
3511+
3512+
**Applies to** : ARM OpenAPI(swagger) specs
3513+
3514+
**Output Message** : The path '{api path}' which is for extension routing resource type, shouldn't include the parent scope.
3515+
3516+
**Description**: Path (operation) for 'extension routing type' (that has additional /providers/ segment in parent scope) must be of the form '{scope}/provider/RPNamespace/resourceTypeName' (shouldn't include parent scope)
3517+
3518+
**CreatedAt**: November 8, 2021
3519+
3520+
**LastModifiedAt**: November 8, 2021
3521+
3522+
**Why this rule is important**: The parent scope won't be passed over to PRaaS, and the API will fail in RPaaS validation.
3523+
3524+
**How to fix the violation**:
3525+
Move the parent resource URI to the 'scope' parameter which is string type.
3526+
3527+
The following would be invalid:
3528+
```json
3529+
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerNamespace}/{resourceType}/{resourceName}/providers/Microsoft.MyProvider/defenderSettings/default"
3530+
```
3531+
The following would be valid :
3532+
3533+
```json
3534+
"{scope}/providers/Microsoft.MyProvider/defenderSettings/default"
3535+
```
3536+
3537+
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)
3538+
3539+
### <a name="r4039"></a>R4039 ParametersOrder
3540+
3541+
**Category** : SDK Error
3542+
3543+
**Applies to** : ARM and Data Plane OpenAPI(swagger) specs
3544+
3545+
**Output Message** : The parameters should be kept in the same order as they present in the path.
3546+
3547+
**Description**: The rule is to ensure the parameters in the same order as they are ranked in the path. Since it can introduce a breaking change when updating parameter order, for services that have already shipped public versions, you may request to suppress the rule following the process documented here: https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/85/Swagger-Suppression-Process
3548+
3549+
**CreatedAt**: November 8, 2021
3550+
3551+
**LastModifiedAt**: November 8, 2021
3552+
3553+
**Why this rule is important**: AutoRest generates SDKs with parameters in the order as they are defined in the Swagger. The only exceptional cases are:
3554+
1. 'body' should be always at last;
3555+
2. 'required' should be always placed before 'optional'
3556+
3557+
**How to fix the violation**:
3558+
re-order the parameters as the order in the api path.
3559+
3560+
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)
3561+
3562+
### <a name="r4040"></a>R4040 EnumMustRespectType
3563+
3564+
**Category** : SDK Error
3565+
3566+
**Applies to** : ARM and Data Plane OpenAPI(swagger) specs
3567+
3568+
**Output Message** : Enum values should respect the type.
3569+
3570+
**Description**: This rule is to check if the enum values conform to the type.
3571+
3572+
**CreatedAt**: November 10, 2021
3573+
3574+
**LastModifiedAt**: November 10, 2021
3575+
3576+
**Why this rule is important**: It will lead to code generation failure in SDK generation pipeline.
3577+
3578+
**How to fix the violation**:
3579+
Just change the enum value to the right type.
3580+
3581+
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)

0 commit comments

Comments
 (0)