Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Chagelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
### 9/12/2017 - 1.9.4
- For `"collectionFormat": "multi"` in `query` parameters, if the item type is null or undefined then we treat it as an empty string
- Removing the check that primaryType in the formatted reference value should only be a string. It can be any other primary type apart from "string".

### 9/5/2017 - 1.9.3
- Added support for `"collectionFormat": "multi"` in `query` parameters https://github.com/Azure/autorest/issues/717.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest.nodejs",
"version": "1.9.3",
"version": "1.9.4",
"description": "The NodeJS extension for classic generators in AutoRest.",
"scripts": {
"start": "dotnet src/bin/netcoreapp2.0/autorest.nodejs.dll --server",
Expand Down
8 changes: 1 addition & 7 deletions src/vanilla/ClientModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static string GetHttpMethod(this HttpMethod method)
}

/// <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>
Expand All @@ -52,12 +52,6 @@ public static string GetFormattedReferenceValue(this Parameter parameter)
primaryType = New<PrimaryType>(KnownPrimaryType.String);
}

if (primaryType == null || primaryType.KnownPrimaryType != KnownPrimaryType.String)
{
throw new InvalidOperationException(
$"Cannot generate a formatted sequence from a non-string array parameter {parameter}");
}

return $"{parameter.Name}.join('{parameter.CollectionFormat.GetSeparator()}')";
}

Expand Down
1 change: 1 addition & 0 deletions src/vanilla/Model/MethodJs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ protected virtual void BuildQueryParameterArray(IndentedStringBuilder builder)
.AppendLine(queryAddFormat, queryParameter.SerializedName, "''").Outdent()
.AppendLine("} else {").Indent()
.AppendLine("for (let item of {0}) {{", queryParameter.Name).Indent()
.AppendLine("item = (item === null || item === undefined) ? '' : item;")
.AppendLine(queryAddFormat, queryParameter.SerializedName, "'' + item").Outdent()
.AppendLine("}").Outdent()
.AppendLine("}").Outdent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ function _getEmpty(accountName, options, callback) {
}
// Validate
try {
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
throw new Error('accountName cannot be null or undefined and it must be of type string.');
}
if (this.client.host === null || this.client.host === undefined || typeof this.client.host.valueOf() !== 'string') {
throw new Error('this.client.host cannot be null or undefined and it must be of type string.');
}
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/AcceptanceTests/acceptanceTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ describe('nodejs', function () {
});
describe('Url MultiFormatCollection Client', function () {
var testClient = new urlMultiCollectionClient(baseUri, clientOptions);
it('should work when query parameter with collection format multi is an empty array', function (done) {
it('should work when query parameter with collection format multi is null', function (done) {
testClient.queries.arrayStringMultiNull(function (err, result, request, response) {
should.not.exist(err);
done();
Expand Down
2 changes: 1 addition & 1 deletion test/vanilla/AcceptanceTests/acceptanceTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,7 @@ describe('nodejs', function () {

describe('Url MultiFormatCollection Client', function () {
var testClient = new urlMultiCollectionClient(baseUri, clientOptions);
it('should work when query parameter with collection format multi is an empty array', function (done) {
it('should work when query parameter with collection format multi is null', function (done) {
testClient.queries.arrayStringMultiNull((err, result, request, response) => {
should.not.exist(err);
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function _arrayStringMultiNull(options, callback) {
queryParameters.push('arrayQuery=' + encodeURIComponent(''));
} else {
for (let item of arrayQuery) {
item = (item === null || item === undefined) ? '' : item;
queryParameters.push('arrayQuery=' + encodeURIComponent('' + item));
}
}
Expand Down Expand Up @@ -188,6 +189,7 @@ function _arrayStringMultiEmpty(options, callback) {
queryParameters.push('arrayQuery=' + encodeURIComponent(''));
} else {
for (let item of arrayQuery) {
item = (item === null || item === undefined) ? '' : item;
queryParameters.push('arrayQuery=' + encodeURIComponent('' + item));
}
}
Expand Down Expand Up @@ -308,6 +310,7 @@ function _arrayStringMultiValid(options, callback) {
queryParameters.push('arrayQuery=' + encodeURIComponent(''));
} else {
for (let item of arrayQuery) {
item = (item === null || item === undefined) ? '' : item;
queryParameters.push('arrayQuery=' + encodeURIComponent('' + item));
}
}
Expand Down