Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into ANF-8208-UpdateSwaggerRestAPI-to-2020-09-01
  • Loading branch information
audunn committed Dec 3, 2020
2 parents bf3339d + 8869dfe commit f69ff78
Show file tree
Hide file tree
Showing 442 changed files with 47,840 additions and 1,406 deletions.
12 changes: 0 additions & 12 deletions .azure-pipelines/Avocado.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .azure-pipelines/LintDiff.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .azure-pipelines/ModelValidation.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .azure-pipelines/Semantic.yml

This file was deleted.

18 changes: 16 additions & 2 deletions .github/pull_request_assignment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,24 @@
- kairu-ms

- rule:
paths: "specification/@(resources|powerplatform)/**"
paths: "specification/@(resources|powerplatform|appplatform)/**"
reviewers:
- raych1

- rule:
paths: "specification/sql/**"
reviewers:
- akning-ms

- rule:
paths: "specification/signalr/**"
reviewers:
- leni-msft

- rule:
paths: "specification/eventhub/**"
reviewers:
- ruowan
- rule:
paths: "specification/compute/**"
reviewers:
Expand All @@ -57,7 +71,7 @@

- rule:
paths:
- "specification/@(azureactivedirectory|appplatform)/**"
- "specification/azureactivedirectory/**"
reviewers:
- njuCZ

Expand Down
4 changes: 0 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ variables:
jobs:
- template: .azure-pipelines/BranchProtectionForPrivateRepo.yml
- template: .azure-pipelines/Syntax.yml
- template: .azure-pipelines/Semantic.yml
- template: .azure-pipelines/Avocado.yml
- template: .azure-pipelines/ModelValidation.yml
- template: .azure-pipelines/LintDiff.yml
- template: .azure-pipelines/NetworkValidation.yml
- template: .azure-pipelines/Spellcheck.yml
- template: .azure-pipelines/PrettierCheck.yml
4 changes: 2 additions & 2 deletions documentation/ci-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Refer to [Oad Docs](https://github.com/Azure/openapi-diff/tree/master/docs) for
Run linter locally:
```
npm install -g autorest
autorest --validation --azure-validator --input-file=<path-to-spec>
autorest --validation --azure-validator --use=@microsoft.azure/classic-openapi-validator@latest --use=@microsoft.azure/openapi-validator@latest --input-file=<path-to-spec>
or
autorest --validation --azure-validator <path-to-readme>
autorest --validation --azure-validator --use=@microsoft.azure/classic-openapi-validator@latest --use=@microsoft.azure/openapi-validator@latest [--tag=<readme tag>] <path-to-readme>
```
Please see [readme](https://github.com/Azure/azure-openapi-validator/blob/master/README.md) for how to install or run tool in details.
Expand Down
219 changes: 217 additions & 2 deletions documentation/openapi-authoring-automated-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| [R4008](#r4008) | [AvoidEmptyResponseSchema](#r4008) | ARM OpenAPI(swagger) specs |
| [R4012](#r4012) | [XmsPageableMustHaveCorrespondingResponse](#r4012) | ARM OpenAPI(swagger) specs |
| [R4013](#r4013) | [IntegerTypeMustHaveFormat](#r4013) | ARM OpenAPI(swagger) specs |
| [R4028](#r4028) | [ValidResponseCodeRequired](#r4028) | ARM OpenAPI(swagger) specs |
| [R4029](#r4029) | [UniqueClientParameterName](#r4029) | ARM OpenAPI(swagger) specs |

#### SDK Warnings

Expand Down Expand Up @@ -141,6 +143,7 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| [R2029](#r2029) | [PageableOperation](#r2029) | ARM and Data plane OpenAPI(swagger) specs |
| [R4006](#r4006) | [DeprecatedXmsCodeGenerationSetting](#r4006) | ARM and Data plane OpenAPI(swagger) specs |
| [R4024](#r4024) | [PreviewVersionOverOneYear](#r4024) | ARM OpenAPI(swagger) specs |
| [R4030](#r4030) | [UniqueXmsExample](#r4030) | ARM OpenAPI(swagger) specs |


### RPaaS Violations
Expand All @@ -150,6 +153,8 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| Id | Rule Name | Applies to |
| --- | --- | --- |
| [R4023](#r4023) | [RPaasPutLongRunningOperation201Only](#r4023) | ARM OpenAPI(swagger) specs |
| [R4025](#r4025) | [RPaasDeleteLongRunningOperation202Only](#r4025) | ARM OpenAPI(swagger) specs |
| [R4026](#r4026) | [RPaasPostLongRunningOperation202Only](#r4026) | ARM OpenAPI(swagger) specs |

### Documentation

Expand Down Expand Up @@ -2929,13 +2934,13 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul

**Output Message** : [RPaaS] Only 201 is the supported response code for PUT async response

**Description** : An async PUT operation response include status code 201 with Azure-async-operation header. Must also support status code 200, for simple updates that can be completed synchronously (ex: tags). Operation must also add "x-ms-long-running-operation and x-ms-long-running-operation-options" to describe how the long running operation is tracked.
**Description** : An async PUT operation response include status code 201 with 'Azure-async-operation' header. Must also support status code 200, for simple updates that can be completed synchronously (ex: tags). Operation must also add "x-ms-long-running-operation and x-ms-long-running-operation-options" to mark that it is a long running operation (in case of 201) and how it is tracked (Azure-async-operation header).

**CreatedAt**: August 10, 2020

**LastModifiedAt**: August 10, 2020

**Why this rule is important**: RPaaS only supports 201 for async operations. This is enforced at runtime via swagger validation.
**Why this rule is important**: RPaaS only supports 201 for async PUT operations. This is enforced at runtime via swagger validation.

**How to fix the violation**: Add the following for async PUT operations.

Expand Down Expand Up @@ -2990,3 +2995,213 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul

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="r4025"></a>R4025 RPaasDeleteLongRunningOperation202Only

**Category** : RPaaS Error

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

**Output Message** : [RPaaS] DELETE async supports

**Description** : An async DELETE operation response include status code 202 with 'Location' header. Must support status code 200 if operation can be completed synchronously. Must support 204 (resource doesn't exists). Operation must also add "x-ms-long-running-operation and x-ms-long-running-operation-options" to mark that it is a long running operation (in case of 202) and how it is tracked (Location header).

**CreatedAt**: November 12, 2020

**LastModifiedAt**: November 12, 2020

**Why this rule is important**: RPaaS only supports 202 for async DELETE operations. This is enforced at runtime via swagger validation.

**How to fix the violation**: Add the following for async DELETE operations.

The following would be valid:

```json
...
"responses": {
"202": {
"description": "Delete operation accepted",
},
"200": {
"description": "Delete operation succeeded"
},
"204": {
"description": "Resource doesn't exist. Delete operation completed."
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation": true,
"x-ms-long-running-operation-options": {
"final-state-via": "location"
}
...
```
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="r4026"></a>R4026 RPaasPostLongRunningOperation202Only

**Category** : RPaaS Error

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

**Output Message** : [RPaaS] POST async supports

**Description** : An async POST operation response include status code 202 with 'Location' header. Must support status code 200 if operation can be completed synchronously. Operation must also add "x-ms-long-running-operation and x-ms-long-running-operation-options" to mark that it is a long running operation (in case of 202) and how it is tracked (Location header).

**CreatedAt**: November 12, 2020

**LastModifiedAt**: November 12, 2020

**Why this rule is important**: RPaaS only supports 202 for async POST operations. This is enforced at runtime via swagger validation.

**How to fix the violation**: Add the following for async POST operations.

The following would be valid:

```json
...
"responses": {
"202": {
"description": "Operation accepted",
},
"200": {
"description": "Operation completed"
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"x-ms-long-running-operation": true,
"x-ms-long-running-operation-options": {
"final-state-via": "location"
}
...
```
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="r4028" ></a>R4028 ValidResponseCodeRequired

**Category** : SDK Error

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

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

**Description** : Every operation response must contain a valid code like "200","201","202" or "204" which indicates the operation is succeed and it's not allowed that a response schema just contains a "default" code.

**Why this rule is important**: If a Swagger just contains "default" status code, this actually means "everything is an error". All track2 SDK will systematically raise an exception at runtime, if there is no declared valid status code.

**CreatedAt**: November 23, 2020

**LastModifiedAt**: November 23, 2020

**How to fix the violation**: Add a valid response code .
The following would be valid:

```json
...
"responses": {
"200": {
"description": "Succeeded",
"schema": {
"$ref": "#/definitions/MySimpleResource"
}
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
...
```
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="r4029" ></a>R4029 UniqueClientParameterName

**Category** : SDK Error

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

**Output Message** : Do not have duplicate name of client parameter name, make sure every client parameter name unique.

**Description** : This may cause a problem when different swagger files come together. If two APIs with different client name have the same client parameter subscriptionId, but with different reference name in swaggers, the generated model will also have two clients with two client parameters subscriptionId and subscriptionId1 (the latter one has been renamed to avoid collision). We should ensure that the client parameters are all unique in the same API version.

**Why this rule is important**: Make sure no conflict in SDK generation.

**CreatedAt**: November 30, 2020

**LastModifiedAt**: November 30, 2020

**How to fix the violation**: Remove duplicate client parameter, ref to the same one.
The following would be valid:

```json
...
"/api": {
"get": {
"parameters": [
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
// ref to the same subcriptionId
"$ref": "#/parameters/subscriptionIdParameter"
},
],
},
"patch": [
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/subscriptionIdParameter"
},
]
}
...
```
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="r4030" ></a>R4030 UniqueXmsExample

**Category** : SDK Warning

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

**Output Message** : Do not have duplicate name of x-ms-example, make sure every x-ms-example name unique. Duplicate x-ms-example: {ExampleName}

**Description** : x-ms-example name should be unique in the same API version.

**Why this rule is important**: Duplicate example name will bring trouble for test codegen. For example: hard to config used example.

**CreatedAt**: November 30, 2020

**LastModifiedAt**: November 30, 2020

**How to fix the violation**: Rename duplicate x-ms-example name
The following would be valid:

```json
...
"x-ms-examples": {
"Create resource": {
"$ref": "./examples/createResource"
},
"Update resource":{
"$ref": "./examples/updateResource"
}

}
...
```
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)
21 changes: 0 additions & 21 deletions preproduction-azure-pipelines.yml

This file was deleted.

Loading

0 comments on commit f69ff78

Please sign in to comment.