Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Conversation

@sarangan12
Copy link
Contributor

When you execute the following command, you get the error:

C:\workspace\autorest.ruby>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 --ruby
AutoRest code generation utility.

(C) 2017 Microsoft Corporation.
https://aka.ms/autorest
Loading AutoRest extension '@microsoft.azure/autorest.ruby' (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.Ruby.Model.ParameterRb
   at AutoRest.Ruby.ClientModelExtensions.GetFormattedReferenceValue(Parameter parameter) in C:\work\oneautorest\autorest.ruby\src\vanilla\ClientModelExtensions.cs:line 207
........
........

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:

C:\workspace\autorest.ruby>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 --ruby --use=C:\workspace\autorest.ruby
AutoRest code generation utility.

(C) 2017 Microsoft Corporation.
https://aka.ms/autorest
Loading local AutoRest extension '@microsoft.azure/autorest.ruby' (C:\workspace\autorest.ruby)
Loading AutoRest extension '@microsoft.azure/autorest.modeler' (1.9.6)

@msftclas
Copy link

msftclas commented Sep 8, 2017

@sarangan12,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

primaryType = New<PrimaryType>(KnownPrimaryType.String);
}

if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String)
Copy link
Contributor

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

Copy link
Contributor Author

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
.....
.....

Copy link
Contributor

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 ?

Copy link
Contributor

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).

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.

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

Copy link
Contributor

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

Copy link
Contributor Author

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

{
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}");
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the comment

@veronicagg veronicagg closed this Sep 8, 2017
@veronicagg veronicagg reopened this Sep 8, 2017
@msftclas
Copy link

msftclas commented Sep 8, 2017

@sarangan12,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Contributor

@veronicagg veronicagg left a 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)

@veronicagg
Copy link
Contributor

veronicagg commented Sep 8, 2017

@sarangan12
Copy link
Contributor Author

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

Copy link
Contributor

@vishrutshah vishrutshah left a 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!

}

if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String)
if (primaryType == null)
Copy link
Contributor

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

@olydis
Copy link
Contributor

olydis commented Sep 26, 2017

publish job

success (version: 2.0.15)

vishrutshah added a commit that referenced this pull request Sep 27, 2017
vishrutshah added a commit that referenced this pull request Sep 27, 2017
…Resource for azure-arm Ruby generator" (#12)

* Revert "Code changes to remove condition to check for known primary type (#7)"

This reverts commit 5b1323c.

* Revert "Updating the inheritance logic for Resoruce & SubResource for azure-arm Ruby generator (#9)"

This reverts commit b14c6ef.
@veronicagg
Copy link
Contributor

Fixing Azure/azure-sdk-for-ruby#944

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants