Skip to content

Commit e81b5f9

Browse files
committed
rebuilt
1 parent 6c41d12 commit e81b5f9

File tree

7 files changed

+34
-28
lines changed

7 files changed

+34
-28
lines changed

browser/swagger-client.js

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/swagger-client.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/http.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ SwaggerHttp.prototype.execute = function (obj, opts) {
7878
data = opts.responseInterceptor.apply(data);
7979
}
8080
error(data);
81-
}
81+
};
8282

8383
obj.on.error = function(data) {
8484
errorInterceptor(data);
85-
}
85+
};
8686

8787
obj.on.response = function(data) {
8888
responseInterceptor(data);
@@ -242,9 +242,10 @@ SuperagentHttpClient.prototype.execute = function (obj) {
242242
}
243243
}
244244
else {
245-
for (var key in obj.body) {
246-
var value = obj.body[key];
247-
r.field(key, value);
245+
var keyname;
246+
for (var keyname in obj.body) {
247+
var value = obj.body[keyname];
248+
r.field(keyname, value);
248249
}
249250
}
250251
}

lib/types/operation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,10 @@ Operation.prototype.asCurl = function (args1, args2) {
981981
} else {
982982
body = obj.body;
983983
}
984+
// escape @ => %40, ' => \u0027, & => %26
985+
body = body.replace(/@/g, '%40').replace(/\'/g, '%27').replace(/&/g, '%26');
984986

985-
results.push('-d \'' + body.replace(/\'/g, '\\u0027') + '\'');
987+
results.push('-d \'' + body + '\'');
986988
}
987989

988990
return 'curl ' + (results.join(' ')) + ' \'' + obj.url + '\'';

test/help.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('help options', function () {
131131
expect(msg).toBe('curl -X GET --header \'Accept: application/json\' \'http://localhost:8080/foo?name=tony|tam\'');
132132
done();
133133
}
134-
})
134+
});
135135
});
136136

137137
it('prints a curl statement with an array of query params and auth', function (done) {
@@ -168,7 +168,7 @@ describe('help options', function () {
168168
expect(msg).toBe("curl -X GET --header 'Accept: application/json' --header 'Authorization: Basic Zm9vOmJhcg==' 'http://localhost:8080/foo?name=tony|tam'");
169169
done();
170170
}
171-
})
171+
});
172172
});
173173

174174
it('prints a curl statement with html', function (done) {
@@ -202,7 +202,7 @@ describe('help options', function () {
202202
expect(msg).toBe("curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{\"description\":\"<b>Test</b>\"}' 'http://localhost:8080/foo'");
203203
done();
204204
}
205-
})
205+
});
206206
});
207207

208208
it('handles post body with html', function (done) {
@@ -233,9 +233,9 @@ describe('help options', function () {
233233
var msg = client.test.sample.asCurl({body: {
234234
description: "<h1>hello world<script>alert('test')</script></h1>"
235235
}});
236-
expect(msg).toBe("curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{\"description\":\"<h1>hello world<script>alert(\\u0027test\\u0027)</script></h1>\"}' 'http://localhost:8080/foo'");
236+
expect(msg).toBe("curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{\"description\":\"<h1>hello world<script>alert(%27test%27)</script></h1>\"}' 'http://localhost:8080/foo'");
237237
done();
238238
}
239-
})
239+
});
240240
});
241241
});

test/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ describe('swagger request functions', function () {
353353
var petApi = sample.pet;
354354
var curl = petApi.addPet.asCurl({body: '{"id":"foo\'bar"}'});
355355

356-
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\'');
356+
expect(curl).toBe('curl -X POST --header \'Content-Type: application/json\' --header \'Accept: application/json\' -d \'{"id":"foo%27bar"}\' \'http://localhost:8000/v2/api/pet\'');
357357
});
358358

359359
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) {

test/resolver.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ describe('swagger resolver', function () {
929929
var opts = opts || {};
930930
opts.url = opts.url || 'http://localhost:8000/v2/absoluteRef.json';
931931
opts.success = function () {
932-
var response = sample.apis.default.operations['get_linked'].successResponse;
932+
var response = sample.apis.default.operations.get_linked.successResponse;
933933
expect(response).toExist();
934934
expect(response['200']).toExist();
935935
done();
@@ -945,9 +945,9 @@ describe('swagger resolver', function () {
945945
opts.success = function () {
946946
expect(sample.swaggerObject.definitions).toExist();
947947
expect(sample.swaggerObject.definitions['error.json']).toExist();
948-
expect(sample.apis.Occupations.operations.post_occupations.parameters[0].schema).toEqual(
948+
expect(sample.apis.Occupations.operations['post_occupations'].parameters[0].schema).toEqual(
949949
{ '$ref': '#/definitions/error.json' });
950-
expect(sample.apis.Occupations.operations.post_occupations.responses['500'].schema).toEqual(
950+
expect(sample.apis.Occupations.operations['post_occupations'].responses['500'].schema).toEqual(
951951
{ '$ref': '#/definitions/error.json' }
952952
);
953953
done();
@@ -1029,7 +1029,7 @@ describe('swagger resolver', function () {
10291029
}
10301030
}
10311031
};
1032-
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec, unresolved) {
1032+
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec) {
10331033
var parameters = spec.paths['/foo'].get.parameters;
10341034
expect(parameters[0].name).toEqual('skip');
10351035
expect(parameters[1].name).toEqual('limit');
@@ -1080,7 +1080,7 @@ describe('swagger resolver', function () {
10801080
},
10811081
definitions : { }
10821082
};
1083-
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec, unresolved) {
1083+
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec) {
10841084
var responses = spec.paths['/'].get.responses;
10851085
expect(responses['200'].description).toBe('Success');
10861086
expect(responses['default'].description).toBe('Error');
@@ -1128,7 +1128,7 @@ describe('swagger resolver', function () {
11281128
}
11291129
}
11301130
};
1131-
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec, unresolved) {
1131+
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec) {
11321132
var parameters = spec.paths['/foo'].get.parameters;
11331133
expect(parameters[0].name).toEqual('skip');
11341134
expect(parameters[1].name).toEqual('limit');
@@ -1178,7 +1178,7 @@ describe('swagger resolver', function () {
11781178
},
11791179
'definitions' : { }
11801180
};
1181-
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec, unresolved) {
1181+
api.resolve(spec, 'http://localhost:8000/v2/swagger.json', function (spec) {
11821182
expect(spec.definitions).toBeAn('object');
11831183
expect(spec.definitions.inline_model).toBeAn('object');
11841184
done();

0 commit comments

Comments
 (0)