-
Notifications
You must be signed in to change notification settings - Fork 14
Code changes to remove condition to check for known primary type #7
Conversation
|
@sarangan12, |
| primaryType = New<PrimaryType>(KnownPrimaryType.String); | ||
| } | ||
|
|
||
| if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String) |
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.
Can you point the reference to the swagger specification where it says any data type is allowed instead of just string? Just for my reference :)
I see that nodeJs has the same case, in that case are they also broken ? https://github.com/Azure/autorest.nodejs/blob/master/src/vanilla/ClientModelExtensions.cs#L55
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.
Can you point the reference to the swagger specification where it says any data type is allowed instead of just string?
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#itemsObject
I see that nodeJs has the same case, in that case are they also broken?
C:\workspace>autorest https://raw.githubusercontent.com/Azure/azure-rest-api-specs/current/specification/trafficmanager/resource-manager/readme.md --output-folder=C:\workspace\temp --azure-arm=True --namespace=Azure::ARM::TrafficManager --package-name=azure_mgmt_traffic_manager --package-version=0.11.0 --nodejs
AutoRest code generation utility.
(C) 2017 Microsoft Corporation.
https://aka.ms/autorest
Installing AutoRest extension '@microsoft.azure/autorest.nodejs' (1.9.3)
Loading AutoRest extension '@microsoft.azure/autorest.modeler' (1.9.6)
FATAL: System.InvalidOperationException: Cannot generate a formatted sequence from a non-string array parameter AutoRest.NodeJS.Model.ParameterJs
at AutoRest.NodeJS.ClientModelExtensions.GetFormattedReferenceValue(Parameter parameter) in D:\sdk\upstream\autorest.nodejs\src\vanilla\ClientModelExtensions.cs:line 61
.....
.....
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.
@amarzavery could you please review this as well ?
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 we be expanding the condition to include"string", "number", "integer", "boolean", or "array", as those are the only types that seem to be allowed per the spec? (I'm not sure "array" makes sense 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.
This is what the spec says
| type | string | Required. The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of "string", "number", "integer", "boolean", "array" or "file". If type is "file", the consumes MUST be either "multipart/form-data", " application/x-www-form-urlencoded" or both and the parameter MUST be in "formData". |
|---|
So technically you could have an array of array of primary type as well.
C# generator is not checking anything over here. https://github.com/Azure/autorest.csharp/blob/master/src/vanilla/ClientModelExtensions.cs#L204 That check was removed completely. I think it is safe to do wha C# has done.
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.
Here is my PR for nodejs Azure/autorest.nodejs#8
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.
👍 Let's make the identical changes to the .NET and nodejs
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.
NodeJS PR will be handled by amarsavery. For .NET SDK, I have created the issue https://github.com/Azure/autorest/issues/2589
src/vanilla/ClientModelExtensions.cs
Outdated
| { | ||
| throw new InvalidOperationException( | ||
| "Cannot generate a formatted sequence from a " + $"non-string array parameter {parameter}"); | ||
| "Cannot generate a formatted sequence from a " + $"null parameter {parameter}"); |
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 update the comment to the function if any primary type is supported.
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.
Updated the comment
|
@sarangan12, |
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.
I've added a comment inline.
One more question: is there any type of "deserialization" of the collection format we're doing anywhere, that would be impacted because the elements may not be strings anymore?
From customer usage point of view, is there any expectation or facility we're providing to construct the CSV (is there anything in the SDK that indicates the type of the values, so the service can deserialize them on the other side per its expectation? - because when they are joined together, they are a "string" for sure)
|
is there any type of "deserialization" of the collection format we're doing anywhere, that would be impacted because the elements may not be strings anymore? Nope |
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.
Also please add the test case so that we don't miss it. Thanks!
src/vanilla/ClientModelExtensions.cs
Outdated
| } | ||
|
|
||
| if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String) | ||
| if (primaryType == null) |
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.
seems like primaryType is not used anywhere. LEt's remove it
publish jobsuccess (version: 2.0.15) |
|
Fixing Azure/azure-sdk-for-ruby#944 |
When you execute the following command, you get the error:
This error is happening because of a condition that was added (and removed in the current PR). Now, after modification, when you execute the command, the SDK is generated without any issues: