This repository was archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Code changes to remove condition to check for known primary type #7
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,7 +179,7 @@ private static string GetSeparator(this CollectionFormat format) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// Format the value of a sequence given the modeled element format. Note that only sequences of strings are supported. | ||
| /// Format the value of a sequence given the modeled element format. | ||
| /// </summary> | ||
| /// <param name="parameter">The parameter to format.</param> | ||
| /// <returns>A reference to the formatted parameter value.</returns> | ||
|
|
@@ -198,10 +198,10 @@ public static string GetFormattedReferenceValue(this Parameter parameter) | |
| primaryType = New<PrimaryType>(KnownPrimaryType.String); | ||
| } | ||
|
|
||
| if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String) | ||
| if (primaryType == null) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like |
||
| { | ||
| 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}"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the comment |
||
| } | ||
|
|
||
| return string.Format("{0}.nil? ? nil : {0}.join('{1}')", parameter.Name, parameter.CollectionFormat.GetSeparator()); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
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
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