Merge pull request #5143 from Azure/fix_runtime_issue
ms-rest need to support dash to the parameter name in path template
This commit is contained in:
Коммит
90cbf77b49
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## 2.5.4
|
||||
|
||||
- Added support for parameter names which contain dash(-) in path template in webResource.
|
||||
|
||||
## 2.5.3
|
||||
|
||||
- Do not serialize default values for model properties.
|
||||
- During deserialization, set the value of an entity to it's default value if specified in the mapper.
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ class WebResource {
|
|||
}
|
||||
let baseUrl = options.baseUrl;
|
||||
let url = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + (options.pathTemplate.startsWith('/') ? options.pathTemplate.slice(1) : options.pathTemplate);
|
||||
let segments = url.match(/({\w*\s*\w*})/ig);
|
||||
let segments = url.match(/({[\w\-]*\s*[\w\-]*})/ig);
|
||||
if (segments && segments.length) {
|
||||
if (options.pathParameters === null || options.pathParameters === undefined || typeof options.pathParameters !== 'object') {
|
||||
throw new Error(`pathTemplate: ${options.pathTemplate} has been provided. Hence, options.pathParameters ` +
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"email": "azsdkteam@microsoft.com",
|
||||
"url": "https://github.com/Azure/azure-sdk-for-node"
|
||||
},
|
||||
"version": "2.5.3",
|
||||
"version": "2.5.4",
|
||||
"description": "Client Runtime for Node.js client libraries generated using AutoRest",
|
||||
"tags": [
|
||||
"node",
|
||||
|
|
|
@ -7,3 +7,4 @@ logFilterTests.js
|
|||
redirectFilterTests.js
|
||||
userAgentFilterTests.js
|
||||
rpRegistrationFilterTests.js
|
||||
webResourceTests.js
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
var assert = require('assert');
|
||||
var webResource = require('../lib/webResource')
|
||||
|
||||
describe('web resoure', function () {
|
||||
|
||||
it('should support dash in parameter name', function (done) {
|
||||
var options = {
|
||||
headers:{
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
method:"get",
|
||||
url:"",
|
||||
pathTemplate:"/pet/{pet-name}/{one-friend-name}",
|
||||
pathParameters: {
|
||||
"pet-name":"tom",
|
||||
"one-friend-name":"jerry"
|
||||
}
|
||||
}
|
||||
var request = new webResource()
|
||||
request = request.prepare(options)
|
||||
assert.equal(request.url,"https://management.azure.com/pet/tom/jerry")
|
||||
done()
|
||||
});
|
||||
});
|
||||
|
Загрузка…
Ссылка в новой задаче