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

Linter Validation rules #1751

Merged
merged 24 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7fc7d03
Adding Validation Rule to check the format for API Version
sarangan12 Dec 21, 2016
aa24132
Fix the regular expression
sarangan12 Dec 22, 2016
abad3fd
Added validation to check the HTTP Verb
sarangan12 Dec 22, 2016
876787a
Added validation to check the properties of resources and their read …
sarangan12 Dec 22, 2016
f2a0b54
Added validation is resource validation must have x-ms-azure-resource…
sarangan12 Dec 23, 2016
3606a82
Fixed the condition
sarangan12 Dec 23, 2016
eea33c1
Added Validation to check if the delete operation have empty body
sarangan12 Dec 27, 2016
63770af
Added validation to validate x-ms-client-name field
sarangan12 Dec 28, 2016
ab73fdf
Fix the signature
sarangan12 Dec 29, 2016
efc0890
Added validation to check the response of put/get/patch operations
sarangan12 Dec 29, 2016
fb5b638
Fixed the signature
sarangan12 Jan 6, 2017
d781245
Added validation to discourage usage of Guid
sarangan12 Jan 6, 2017
bcd2366
Added code to validate if operations API has been implemented
sarangan12 Jan 11, 2017
00426cb
Added code to validate tracked resources
sarangan12 Jan 12, 2017
6d9d811
Added code to validate properties of tracked resources
sarangan12 Jan 13, 2017
d3769c9
Additional changes
sarangan12 Jan 26, 2017
4506ec7
Merge remote-tracking branch 'origin' into ValidationRules
sarangan12 Jan 26, 2017
2630213
Fix the Build Issue
sarangan12 Jan 27, 2017
ffd031a
Response to PR comments
sarangan12 Jan 31, 2017
22b4a27
Merge remote-tracking branch 'origin/master' into ValidationRules
sarangan12 Jan 31, 2017
81d7efd
Added Test cases
sarangan12 Feb 1, 2017
c943203
Added more test cases
sarangan12 Feb 2, 2017
312b726
Fixing test cases
sarangan12 Feb 2, 2017
d9760e8
Removed circular dependency test case
sarangan12 Feb 2, 2017
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
104 changes: 104 additions & 0 deletions src/core/AutoRest.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions src/core/AutoRest.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,41 @@
<data name="MsdnReferencesDiscouraged" xml:space="preserve">
<value>For better generated code quality, remove all references to "msdn.microsoft.com".</value>
</data>
<data name="APIVersionFormatIsNotValid" xml:space="preserve">
<value>API Version must be in the format: yyyy-MM-dd, optionally followed by -preview, -alpha, -beta, -rc, -privatepreview.</value>
</data>
<data name="HttpVerbIsNotValid" xml:space="preserve">
<value>Permissible values for HTTP Verb are delete,get,put,patch,head,options,post. </value>
</data>
<data name="ResourceModelIsNotValid" xml:space="preserve">
<value>The id, name, type, location and tags properties of the Resource must be present with id, name and type as read-only</value>
</data>
<data name="ResourceIsMsResourceNotValid" xml:space="preserve">
<value>A 'Resource' definition must have x-ms-azure-resource extension enabled and set to true.</value>
</data>
<data name="XmsClientNameInValid" xml:space="preserve">
<value>Value of 'x-ms-client-name' cannot be the same as the property/model name.</value>
</data>
<data name="DeleteMustHaveEmptyRequestBody" xml:space="preserve">
<value>'Delete' operation cannot have parameters in the request body.</value>
</data>
<data name="SkuModelIsNotValid" xml:space="preserve">
<value>Sku Model is not valid. A Sku model must have name property. It can also have tier, size, family, capacity as optional properties.</value>
</data>
<data name="PutGetPatchResponseInvalid" xml:space="preserve">
<value>{0} has different responses for PUT/GET/PATCH operations. The PUT/GET/PATCH operations must have same schema response.</value>
</data>
<data name="OperationsAPINotImplemented" xml:space="preserve">
<value>Operations API must be implemented for the service.</value>
</data>
<data name="TrackedResourceIsNotValid" xml:space="preserve">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule does not accurately represent whether the tracked resource is valid or not. So the rule name /description can be misleading. Ex- The listByResourceGroup and listBySubscription need not be present for tracked nested resources. So we should Run 2. and 3. checks only for tracked parents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synched and cleared offline

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule does not accurately represent whether the tracked resource is valid or not. So the rule name /description can be misleading. Ex- The listByResourceGroup and listBySubscription need not be present for tracked nested resources. So we should Run 2. and 3. checks only for tracked parents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synched and cleared offline

<value>Tracked Resource failing validation is: {0}. Validation Failed: {1}.
A Tracked Resource must have:
1. A Get Operation
2. A ListByResourceGroup operation with x-ms-pageable extension and
3. A ListBySubscriptionId operation with x-ms-pageable extension.
4. Type, Location, Tags should not be used in the properties.</value>
</data>
<data name="BodyMustHaveSchema" xml:space="preserve">
<value>Each body parameter must have a schema</value>
</data>
Expand Down Expand Up @@ -273,6 +308,9 @@
<data name="PathCannotBeNullOrEmpty" xml:space="preserve">
<value>path cannot be null or an empty string or a string with white spaces while getting the parent directory</value>
</data>
<data name="GuidUsageNotRecommended" xml:space="preserve">
<value>Guid used at the #/Definitions/{1}/.../{0}. Usage of Guid is not recommanded. If GUIDs are absolutely required in your service, please get sign off from the Azure API review board.</value>
</data>
<data name="OperationNameNotValid" xml:space="preserve">
<value>'GET' operation must use method name 'Get' or Method name start with 'List', 'PUT' operation must use method name 'Create', 'PATCH' operation must use method name 'Update' and 'DELETE' operation must use method name 'Delete'.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"version": "2016-08-10",
"title": "Swagger Petstore",
"license": {
"name": "MIT"
Expand All @@ -19,6 +19,34 @@
"application/json"
],
"paths": {
"/operations": {
"get": {
"summary": "Lists all foo.",
"description": "foo",
"operationId": "Operations_List",
"parameters": [
{
"name": "limit",
"type": "string",
"description": "foo"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/OperationsListResult"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets": {
"get": {
"summary": "List all pets",
Expand Down Expand Up @@ -273,6 +301,45 @@
"x-ms-client-flatten": true
}
}
},
"OperationsListResult": {
"description": "List of operations",
"properties": {
"value": {
"type": "array",
"items": {
"$ref": "#/definitions/Operation"
},
"description": "List of Operations"
}
}
},
"Operation": {
"description": "Description of Operation",
"type": "object",
"properties": {
"name": {
"description": "Operation name",
"type": "string"
},
"display": {
"description": "foo",
"properties": {
"provider": {
"description": "Service provider",
"type": "string"
},
"resource": {
"description": "Resource on which the operation is performed: Profile, endpoint, etc.",
"type": "string"
},
"operation": {
"description": "Operation type: Read, write, delete, etc.",
"type": "string"
}
}
}
}
}
}
}
Loading