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

Added support for deprecated operations and paths #149

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@
[1039 - AddedOperation](rules/1039.md)

[1040 - AddedReadOnlyPropertyInResponse](rules/1040.md)

[1041 - RemovedDeprecatedOperation](rules/1041.md)

[1042 - RemovedDeprecatedPath](rules/1042.md)
71 changes: 71 additions & 0 deletions docs/rules/1041.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
### 1041 - RemovedDeprecatedOperation

**Description**: Checks whether an existing operation with `deprecated: true` from a path is removed from the previous specification.

**Cause**: This is considered a change but not necessarily breaking. Removing deprecated operations can be a part of planned maintenance.

**Example**: Deprecated operation `get` from Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being removed.

Old specification
```json5
{
"swagger": "2.0",
"info": {
"title": "swagger",
"description": "The Azure Management API.",
"version": "2016-12-01",
...
...
"paths": {
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
"get": {
...
},
"put": {
...
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
"get": {
...
"deprecated": true
},
"delete": {
...
}
}
...
...
```

New specification
```json5
{
"swagger": "2.0",
"info": {
"title": "swagger",
"description": "The Azure Management API.",
"version": "2016-12-01",
...
...
"paths": {
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
"get": {
...
},
"put": {
...
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
"post": {
...
},
"delete": {
...
}
}
...
...
```

63 changes: 63 additions & 0 deletions docs/rules/1042.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
### 1042 - RemovedDeprecatedPath

**Description**: Checks whether a deprecated path is removed from the previous specification. A path is considered deprecated when all its operations are deprecated

**Cause**: This is considered change but not necessarily breaking. Removing deprecated paths can be a part of planned maintenance.

**Example**: Path `/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1` is being removed.

Old specification
```json5
{
"swagger": "2.0",
"info": {
"title": "swagger",
"description": "The Azure Management API.",
"version": "2016-12-01",
...
...
"paths": {
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
"get": {
...
},
"put": {
...
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1/subResource1": {
"get": {
...
"deprecated": true
},
"delete": {
...
"deprecated": true
}
}
...
...
```

New specification
```json5
{
"swagger": "2.0",
"info": {
"title": "swagger",
"description": "The Azure Management API.",
"version": "2016-12-01",
...
...
"paths": {
"/subscriptions/{subscriptionId}/providers/Microsoft.Contoso/resource1": {
"get": {
...
},
"put": {
...
}
}
...
...
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<Content Include="Resource\Swagger\new\operation_check_05.json" />
<Content Include="Resource\Swagger\new\param_check_01.json" />
<Content Include="Resource\Swagger\new\removed_definition.json" />
<Content Include="Resource\Swagger\new\removed_deprecated_operation.json" />
<Content Include="Resource\Swagger\old\removed_deprecated_path.json" />
<Content Include="Resource\Swagger\new\removed_operation.json" />
<Content Include="Resource\Swagger\new\removed_path.json" />
<Content Include="Resource\Swagger\new\required_parameter.json" />
Expand Down Expand Up @@ -52,6 +54,8 @@
<Content Include="Resource\Swagger\old\recursive_model.json" />
<Content Include="Resource\Swagger\old\changed_operation_id.json" />
<Content Include="Resource\Swagger\old\added_path.json" />
<Content Include="Resource\Swagger\old\removed_deprecated_operation.json" />
<Content Include="Resource\Swagger\old\removed_deprecated_path.json" />
<Content Include="Resource\Swagger\old\required_parameter.json" />
<Content Include="Resource\Swagger\old\removed_operation.json" />
<Content Include="Resource\Swagger\old\removed_path.json" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"swagger": 2.0,
"info": {
"title": "removed_deprecated_operation",
"version": "1.0"
},
"host": "localhost:8000",
"schemes": [ "http", "https" ],
"paths": {
"/api/Paths": {
"get": {
"tag": [ "Paths" ],
"operationId": "Paths_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
},
"/api/Operations": {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"swagger": 2.0,
"info": {
"title": "removed_deprecated_path",
"version": "1.0"
},
"host": "localhost:8000",
"schemes": [ "http", "https" ],
"paths": {
"/api/Paths": {
"get": {
"tag": [ "Paths" ],
"operationId": "Paths_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
},
"/api/Operations": {
"get": {
"tag": [ "Operations" ],
"operationId": "Operations_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
},
"post": {
"tag": [ "Operations" ],
"operationId": "Operations_Post",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"swagger": 2.0,
"info": {
"title": "removed_deprecated_operation",
"version": "1.0"
},
"host": "localhost:8000",
"schemes": [ "http", "https" ],
"paths": {
"/api/Paths": {
"get": {
"tag": [ "Paths" ],
"operationId": "Paths_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
},
"/api/Operations": {
"get": {
"tag": [ "Operations" ],
"operationId": "Operations_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {},
"deprecated": true
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"swagger": 2.0,
"info": {
"title": "removed_deprecated_path",
"version": "1.0"
},
"host": "localhost:8000",
"schemes": [ "http", "https" ],
"paths": {
"/api/Paths": {
"get": {
"tag": [ "Paths" ],
"operationId": "Paths_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
},
"/api/Operations": {
"get": {
"tag": [ "Operations" ],
"operationId": "Operations_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
},
"post": {
"tag": [ "Operations" ],
"operationId": "Operations_Post",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {}
}
},
"/api/Parameters/{a}": {
"get": {
"tag": [ "Parameters" ],
"operationId": "Parameters_Get",
"produces": [
"text/plain"
],
"parameters": [
{
"name": "a",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "b",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "d",
"in": "query",
"required": true,
"type": "string"
},
{
"name": "e",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "f",
"in": "query",
"required": true,
"type": "string",
"enum": [ "theonlyvalue" ]
}
],
"deprecated": true
}
},
"/api/Responses": {
"get": {
"tag": [ "Responses" ],
"operationId": "Responses_Get",
"produces": [
"text/plain"
],
"parameters": [],
"responses": {
"200": {
"schema": {
"type": "integer"
}
},
"201": {
"schema": {
"type": "integer"
}
},
"400": {
"schema": {
"type": "object",
"properties": {
"message": { "type": "string" },
"id": { "type": "string" }
}
}
}
},
"deprecated": true
}
}
}
}
Loading