Skip to content

Commit

Permalink
Linter Validation rules (#1751)
Browse files Browse the repository at this point in the history
* Adding Validation Rule to check the format for API Version

* Fix the regular expression

* Added validation to check the HTTP Verb

* Added validation to check the properties of resources and their read only preoperties

* Added validation is resource validation must have x-ms-azure-resource extension

* Fixed the condition

* Added Validation to check if the delete operation have empty body

* Added validation to validate x-ms-client-name field

* Fix the signature

* Added validation to check the response of put/get/patch operations

* Fixed the signature

* Added validation to discourage usage of Guid

* Added code to validate if operations API has been implemented

* Added code to validate tracked resources

* Added code to validate properties of tracked resources

* Additional changes

* Fix the Build Issue

* Response to PR comments

* Added Test cases

* Added more test cases

* Fixing test cases

* Removed circular dependency test case
  • Loading branch information
sarangan12 authored and amarzavery committed Feb 3, 2017
1 parent 019e58f commit 9e7956e
Show file tree
Hide file tree
Showing 38 changed files with 3,970 additions and 21 deletions.
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">
<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

0 comments on commit 9e7956e

Please sign in to comment.