Skip to content

Commit 57fdc0d

Browse files
committed
Outputs curl URL in single quotes
1 parent 1727d56 commit 57fdc0d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

lib/types/operation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ Operation.prototype.asCurl = function (args1, args2) {
885885
results.push('-d \'' + body.replace(/\'/g, '\\u0027') + '\'');
886886
}
887887

888-
return 'curl ' + (results.join(' ')) + ' "' + obj.url + '"';
888+
return 'curl ' + (results.join(' ')) + ' \'' + obj.url + '\'';
889889
};
890890

891891
Operation.prototype.encodePathCollection = function (type, name, value) {

test/compat/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('1.2 request operations', function () {
3434
it('shows curl syntax', function () {
3535
var curl = sample.pet.getPetById.asCurl({petId: 1});
3636

37-
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' "http://localhost:8001/v1/api/pet/1"');
37+
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' \'http://localhost:8001/v1/api/pet/1\'');
3838
});
3939

4040
it('generate a get request', function () {

test/help.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('help options', function () {
3939
{summary: 'test operation'}, {}, {}, new auth.SwaggerAuthorizations());
4040
var curl = op.asCurl({});
4141

42-
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' "http://localhost/path"');
42+
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' \'http://localhost/path\'');
4343
});
4444

4545
it('does not duplicate api_key in query param per #624', function () {
@@ -56,7 +56,7 @@ describe('help options', function () {
5656
// repeat to ensure no change
5757
curl = op.asCurl({});
5858

59-
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' "http://localhost/path?api_key=abc123"');
59+
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' \'http://localhost/path?api_key=abc123\'');
6060
});
6161

6262
it('prints a curl statement with headers', function () {
@@ -86,7 +86,7 @@ describe('help options', function () {
8686
Authorization: 'Oauth:"test"'
8787
});
8888

89-
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' --header \'name: tony\' --header \'age: 42\' --header \'Authorization: Oauth:"test"\' "http://localhost/path"');
89+
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' --header \'name: tony\' --header \'age: 42\' --header \'Authorization: Oauth:"test"\' \'http://localhost/path\'');
9090
});
9191

9292
it('prints a curl statement with custom content-type', function () {
@@ -96,6 +96,6 @@ describe('help options', function () {
9696
responseContentType: 'application/xml'
9797
});
9898

99-
expect(curl).toBe('curl -X GET --header \'Accept: application/xml\' "http://localhost/path"');
99+
expect(curl).toBe('curl -X GET --header \'Accept: application/xml\' \'http://localhost/path\'');
100100
});
101101
});

test/request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,21 @@ describe('swagger request functions', function () {
303303
var petApi = sample.pet;
304304
var curl = petApi.addPet.asCurl({body: {id:10101}});
305305

306-
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":10101}\' "http://localhost:8000/v2/api/pet"');
306+
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":10101}\' \'http://localhost:8000/v2/api/pet\'');
307307
});
308308

309309
it('prints a curl post statement from a string', function () {
310310
var petApi = sample.pet;
311311
var curl = petApi.addPet.asCurl({body: '{"id":10101}'});
312312

313-
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":10101}\' "http://localhost:8000/v2/api/pet"');
313+
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":10101}\' \'http://localhost:8000/v2/api/pet\'');
314314
});
315315

316316
it('prints a curl post statement from a string containing a single quote', function () {
317317
var petApi = sample.pet;
318318
var curl = petApi.addPet.asCurl({body: '{"id":"foo\'bar"}'});
319319

320-
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":"foo\\u0027bar"}\' "http://localhost:8000/v2/api/pet"');
320+
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":"foo\\u0027bar"}\' \'http://localhost:8000/v2/api/pet\'');
321321
});
322322

323323
it('gets an server side 404, and verifies that the content-type in the response is correct, and different than one in the request', function (done) {

0 commit comments

Comments
 (0)