Cognitive Services swagger api-version 2017-04-18 initial commit#1090
Cognitive Services swagger api-version 2017-04-18 initial commit#1090veronicagg merged 7 commits intoAzure:masterfrom
Conversation
1. Support Cognitive Service RP version - 2017-04-18 2. Add following operations and related parameter definitions: a. POST updateAccountsCreationSettings b. GET accountsCreationSettings c. POST checkSkuAvailability d. Get operations 3. Fix all issues reported by AutoRest/Validate-Spec/Validate-Example. 4. Examples are removed from this swagger file – will add them to dedicated example folder later.
| "required": true, | ||
| "x-ms-client-flatten": true, | ||
| "schema": { | ||
| "$ref": "#/definitions/CognitiveServicesResourceKindSettingUpdateParameter" |
There was a problem hiding this comment.
ResourceKindSetting => AccountsCreationSettings?
| "allowCreate": { | ||
| "type": "string", | ||
| "description": "Whether allow user to create resource.", | ||
| "enum": [ |
There was a problem hiding this comment.
It supports but AutoRest suggests to use Enum instead of Boolean.
There was a problem hiding this comment.
the suggestion from AutoRest is to evaluate if the property is really a boolean or not, the intent is to consider if there could be more than 2 values possible for the property in the future or not, if the answer is no, then a boolean is fine, if the answer is yes, there could be other values, then make it an enum with values that represent what those should be. The idea is that it can help avoid breaking changes if you want to add one more possible value, naming the values "true", "false" I believe defeats this purpose.
There was a problem hiding this comment.
I suggest AutoRest can turn off this warning though.
|
@felixwa thanks for submitting this PR. |
| "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" | ||
| }, | ||
| { | ||
| "name": "body", |
There was a problem hiding this comment.
should this be named "parameters"?
There was a problem hiding this comment.
Changed all places to "parameters".
| "post": { | ||
| "tags": [ "CognitiveServicesAccounts" ], | ||
| "operationId": "CheckSkuAvailability_List", | ||
| "description": "Check availalable SKUs.", |
| "200": { | ||
| "description": "OK.", | ||
| "schema": { | ||
| "$ref": "#/definitions/CheckSkuAvailabilityResultList" |
There was a problem hiding this comment.
is this a pageable operation?
| "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/updateAccountsCreationSettings": { | ||
| "post": { | ||
| "tags": [ "CognitiveServicesAccounts" ], | ||
| "operationId": "CognitiveServices_UpdateResourceKindSettings", |
There was a problem hiding this comment.
is this operation id accurate for the operation path?
| "$ref": "#/parameters/locationParameter" | ||
| }, | ||
| { | ||
| "name": "body", |
There was a problem hiding this comment.
should this be named "parameters"?
There was a problem hiding this comment.
Changed all places to "parameters".
| "required": true, | ||
| "type": "string", | ||
| "enum": [ "current" ], | ||
| "description": "Accounts creation setting name, now only support \"current\".", |
There was a problem hiding this comment.
are you planning on adding other values? If there's only one value in the enum on a required parameter, then it's value will be taken as a constant (https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md#single-value-enum-as-a-constant)
You could just write that value in the path as a constant, if you're not planning on adding more values.
There was a problem hiding this comment.
This operation has been changed to POST after more discussions with ARM team. This "current" has gone.
| "200": { | ||
| "description": "OK", | ||
| "schema": { | ||
| "$ref": "#/definitions/CognitiveServicesResourceKindSettingResult" |
There was a problem hiding this comment.
is this a pageable operation?
| "skuAvailable": { | ||
| "type": "string", | ||
| "description": "Indicates the given SKU is available or not.", | ||
| "enum": [ |
There was a problem hiding this comment.
should this be a boolean? are there other values this property may accept?
| "allowCreate": { | ||
| "type": "string", | ||
| "description": "Whether allow user to create resource.", | ||
| "enum": [ |
There was a problem hiding this comment.
should this be a boolean? could this property accept other values?
| "allowCreate": { | ||
| "type": "string", | ||
| "description": "Whether allow user to create resource.", | ||
| "enum": [ |
There was a problem hiding this comment.
the suggestion from AutoRest is to evaluate if the property is really a boolean or not, the intent is to consider if there could be more than 2 values possible for the property in the future or not, if the answer is no, then a boolean is fine, if the answer is yes, there could be other values, then make it an enum with values that represent what those should be. The idea is that it can help avoid breaking changes if you want to add one more possible value, naming the values "true", "false" I believe defeats this purpose.
Commit original 2016-02-01-preview version for comparison purpose
Fix review comments from veronicagg
Fix a typo.
|
@veronicagg , I have commit 2016-02-01-preview version then made another commit to overwrite it with 2017-04-18 version. Let me know if this works for you. |
|
@felixwa thanks for committing the previous version! Regarding the latest version of autorest, here are the update instructions for autorest: https://github.com/Azure/autorest#updating-autorest (just to make sure you're running the latest - Travis should be using the latest). |
|
@felixwa should you be adding "securityDefinitions" section, similar to https://github.com/Azure/azure-rest-api-specs/blob/master/arm-analysisservices/2016-05-16/swagger/analysisservices.json#L26 ? |
| "in": "body", | ||
| "required": true, | ||
| "schema": { | ||
| "$ref": "#/definitions/CognitiveServicesAccountCreateParameters" |
There was a problem hiding this comment.
CognitiveServicesAccountCreateParameters [](start = 37, length = 40)
Is there a reason for the body parameter and the response not being the same model? Please consider this rule" "M2017: The model definition for the body parameter and the response MUST be the same for a PUT operation. This ensures that the same entity will be reusable between GET and PUT." (from https://github.com/Azure/azure-rest-api-specs/blob/62c96876795e600de8369efe42edd3a70f494017/documentation/swagger-checklist.md)
There was a problem hiding this comment.
@veronicagg , we followed RPC v2. In PUT body, there is no need to put id/name/type etc. there because they are already there in URL.
There was a problem hiding this comment.
@felixwa would you consider changing this in the future? Users of the api won't be able to reuse the same identity between GET and PUT ("This ensures that the same entity will be reusable between GET and PUT." ). There will be an error shown by our validation tools on this soon.
There was a problem hiding this comment.
Ok we could consider that if the tool will report this anyway. Will that be a breaking change for RP and/or this swagger file?
There was a problem hiding this comment.
It would be a breaking change for the SDK, so it'd need to be done consciously.
| "properties": { | ||
| "sku": { | ||
| "$ref": "#/definitions/Sku", | ||
| "description": "Required. Gets or sets the SKU of the resource." |
There was a problem hiding this comment.
Please take a look at: "M2016: For PATCH operation, every property in the model for the request body MUST be optional and the property MUST NOT provide any default value. The absence of default values applies recursively to complex properties in the model definition." (from https://github.com/Azure/azure-rest-api-specs/blob/62c96876795e600de8369efe42edd3a70f494017/documentation/swagger-checklist.md)
The description says this is required, I don't this marked as required, but the Sku model has "name" as required.
There was a problem hiding this comment.
Not required. I have revised the "description".
| ], | ||
| "description": "The SKU of the cognitive services account." | ||
| }, | ||
| "CognitiveServicesAccountPropertiesCreateParameters": { |
There was a problem hiding this comment.
CognitiveServicesAccountPropertiesCreateParameters [](start = 5, length = 50)
is there no type for this model? object?
There was a problem hiding this comment.
This is just a placeholder actually. The RP SDK requires this field but we don't have any properties in it.
There was a problem hiding this comment.
I'm not sure I understand this, could you clarify? "properties" is also a required property, what would the user input to this property? what would you include in your example for this case?
There was a problem hiding this comment.
Like below:
{
"sku":{
"name": "S0"
},
"location": "westeurope",
"kind": "Face",
"properties": {}
}
User would input nothing in the "properties" field. For our RP it is not required, it is just RP SDK requires that field present there.
| }, | ||
| "properties": { | ||
| "x-ms-client-flatten": true, | ||
| "$ref": "#/definitions/CognitiveServicesAccountPropertiesCreateParameters", |
There was a problem hiding this comment.
CognitiveServicesAccountPropertiesCreateParameters [](start = 33, length = 50)
what is this flattening? I don't see any properties in the referenced model.
There was a problem hiding this comment.
Removed (but AutoRest reports a new warning).
veronicagg
left a comment
There was a problem hiding this comment.
Please see some more questions/comments inline.
1. Change account name max/min length to be consistent with UI. 2. Resolved some review comments. 3. Fix some issues with CheckSkuAvailability operation.
|
@veronicagg , I have added securityDefinitions and resolved some review comments. |
veronicagg
left a comment
There was a problem hiding this comment.
Please see reply to a couple of your comments.
Adding examples for every operation. Fix some issues found when adding examples.
|
@veronicagg , I have added examples for every operation. |
| "message": { | ||
| "type": "string", | ||
| "description": "Additional error message." | ||
| } |
There was a problem hiding this comment.
@veronicagg , I noticed that validate-example reports warnings for these 2 fields because the in example they are null. I tried to make the type ["string", "null"] but then AutoRest reports errors then.
Please advice how to make tools happy in this case.
|
Regarding the "properties" that I asked before, is there a reason why there is a $ref in that case and not something like? or even without "additionalProperties"? |
Remove CognitiveServicesAccountPropertiesCreateParameters, make it "inline" and refine description. We still need it because currently the underlying SDK requires it.
|
@veronicagg , I have removed that CognitiveServicesAccountPropertiesCreateParameters and make it "inline" as you suggested. |
|
No modification for Ruby |
|
No modification for NodeJS |
|
No modification for Python |
a. POST updateAccountsCreationSettings
b. GET accountsCreationSettings
c. POST checkSkuAvailability
d. Get operations
dedicated example folder later.
This checklist is used to make sure that common issues in a pull request are addressed. This will expedite the process of getting your pull request merged and avoid extra work on your part to fix issues discovered during the review process.
PR information
api-versionin the path should match theapi-versionin the spec).Quality of Swagger