-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Cognitive Services swagger api-version 2017-04-18 initial commit #1090
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
Cognitive Services swagger api-version 2017-04-18 initial commit #1090
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResourceKindSetting => AccountsCreationSettings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
| "allowCreate": { | ||
| "type": "string", | ||
| "description": "Whether allow user to create resource.", | ||
| "enum": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it support Boolean type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It supports but AutoRest suggests to use Enum instead of Boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest AutoRest can turn off this warning though.
|
@felixwa thanks for submitting this PR. |
veronicagg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments inline.
| "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$" | ||
| }, | ||
| { | ||
| "name": "body", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be named "parameters"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed all places to "parameters".
| "post": { | ||
| "tags": [ "CognitiveServicesAccounts" ], | ||
| "operationId": "CheckSkuAvailability_List", | ||
| "description": "Check availalable SKUs.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in "available"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix.
| "200": { | ||
| "description": "OK.", | ||
| "schema": { | ||
| "$ref": "#/definitions/CheckSkuAvailabilityResultList" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a pageable operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
| "/subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/updateAccountsCreationSettings": { | ||
| "post": { | ||
| "tags": [ "CognitiveServicesAccounts" ], | ||
| "operationId": "CognitiveServices_UpdateResourceKindSettings", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this operation id accurate for the operation path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| "$ref": "#/parameters/locationParameter" | ||
| }, | ||
| { | ||
| "name": "body", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be named "parameters"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a pageable operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
| "skuAvailable": { | ||
| "type": "string", | ||
| "description": "Indicates the given SKU is available or not.", | ||
| "enum": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a boolean? are there other values this property may accept?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Boolean.
| "allowCreate": { | ||
| "type": "string", | ||
| "description": "Whether allow user to create resource.", | ||
| "enum": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required. I have revised the "description".
| ], | ||
| "description": "The SKU of the cognitive services account." | ||
| }, | ||
| "CognitiveServicesAccountPropertiesCreateParameters": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CognitiveServicesAccountPropertiesCreateParameters [](start = 5, length = 50)
is there no type for this model? object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed (but AutoRest reports a new warning).
veronicagg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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