Skip to content

Commit 45b48e6

Browse files
committed
merged
2 parents 3056119 + 6530b7d commit 45b48e6

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

browser/swagger-client.js

Lines changed: 4 additions & 1 deletion
Large diffs are not rendered by default.

browser/swagger-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/types/operation.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,9 @@ Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) {
924924

925925
this.clientAuthorizations.apply(obj, this.operation.security);
926926
if (opts.mock === true) {
927+
if(opts.requestInterceptor) {
928+
opts.requestInterceptor.apply(obj);
929+
}
927930
return obj;
928931
} else {
929932
return new SwaggerHttp().execute(obj, opts);

test/request.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,19 @@ describe('swagger basePath override functions', function () {
510510
});
511511
});
512512

513+
it('applies a request interceptor to asCurl #903', function() {
514+
var petApi = sample.pet;
515+
var requestInterceptor = {
516+
apply: function(data) {
517+
data.url = 'http://localhost:8000/v2/api/pet/1';
518+
return data;
519+
}
520+
};
521+
522+
var curl = petApi.getPetById.asCurl({petId: -100}, {requestInterceptor: requestInterceptor});
523+
expect(curl).toBe('curl -X GET --header \'Accept: application/json\' \'http://localhost:8000/v2/api/pet/1\'');
524+
});
525+
513526
it('applies request interceptor and waits for beforeSend as per #701', function(done) {
514527
this.timeout(10000);
515528
var petApi = sample.pet;

0 commit comments

Comments
 (0)