Skip to content

Commit 6229f4f

Browse files
committed
Pull from master
2 parents 59dce84 + 92f3f25 commit 6229f4f

File tree

6 files changed

+88
-82
lines changed

6 files changed

+88
-82
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"angular-ui-layout": "^1.4.2",
3737
"angular-ui-router": "^0.3.1",
3838
"bootstrap": "^3.3.6",
39-
"brace": "^0.8.0",
39+
"brace": "^0.9.1",
4040
"chai": "^3.5.0",
41-
"css-loader": "^0.23.1",
42-
"es6-promise": "^3.1.2",
41+
"css-loader": "^0.26.1",
42+
"es6-promise": "^4.0.5",
4343
"es6-shim": "^0.35.0",
4444
"eslint": "^2.13.1",
4545
"eslint-config-google": "^0.6.0",
@@ -58,12 +58,12 @@
5858
"json-editor": "^0.7.26",
5959
"json-formatter-js": "^1.0.0",
6060
"json-loader": "^0.5.4",
61-
"json-schema-view-js": "^0.4.1",
61+
"json-schema-view-js": "^1.0.0",
6262
"jsonformatter": "^0.6.0",
6363
"jsonlint": "^1.6.2",
6464
"karma": "^1.1.0",
65-
"karma-chai-plugins": "^0.7.0",
66-
"karma-chrome-launcher": "^1.0.1",
65+
"karma-chai-plugins": "^0.8.0",
66+
"karma-chrome-launcher": "^2.0.0",
6767
"karma-firefox-launcher": "^1.0.0",
6868
"karma-jasmine": "^1.0.2",
6969
"karma-mocha": "^1.1.1",
@@ -76,20 +76,20 @@
7676
"less-loader": "^2.2.2",
7777
"lodash": "^4.6.1",
7878
"minimist": "^1.2.0",
79-
"mocha": "^2.4.5",
79+
"mocha": "^3.2.0",
8080
"mversion": "^1.10.1",
8181
"ng-annotate-webpack-plugin": "^0.1.3",
8282
"ng-file-upload": "^12.0.4",
8383
"ngstorage": "^0.3.10",
8484
"open": "0.0.5",
8585
"open-sans-fontface": "^1.4.0",
86-
"protractor": "^3.2.1",
86+
"protractor": "^4.0.14",
8787
"sinon": "^1.17.3",
8888
"sinon-chai": "^2.8.0",
8989
"source-code-pro": "https://github.com/adobe-fonts/source-code-pro.git#release",
90-
"spark-md5": "^2.0.2",
90+
"spark-md5": "^3.0.0",
9191
"style-loader": "^0.13.0",
92-
"svg-inline-loader": "^0.6.0",
92+
"svg-inline-loader": "^0.7.1",
9393
"sway": "^1.0.0",
9494
"url-loader": "^0.5.7",
9595
"webpack": "^1.12.14",

scripts/controllers/tryoperation.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SwaggerEditor.controller('TryOperation', function($scope, formdataFilter,
7575
loose = true;
7676
}
7777
}
78-
} catch (e) {}
78+
} catch (e) {} // eslint-disable-line no-empty
7979
} else {
8080
loose = false;
8181
}
@@ -738,17 +738,23 @@ SwaggerEditor.controller('TryOperation', function($scope, formdataFilter,
738738
var formData = new FormData();
739739
parameters
740740
.filter(function(parameter) {
741-
return parameter.type === 'file';
741+
return parameter.type === 'file' || parameter.in === 'formData';
742742
})
743743
.forEach(function(parameter) {
744-
var fileInput = $('[data-schemapath="root.parameters"]' +
745-
' [name="root[parameters][' + parameter.name + ']"]');
746-
if (fileInput[0] && fileInput[0].files) {
747-
var file = fileInput[0].files[0];
748-
if (file) {
749-
formData.append(parameter.name, file, file.name);
744+
if (parameter.type === 'file') {
745+
var fileInput = $('[data-schemapath="root.parameters"]' +
746+
' [name="root[parameters][' + parameter.name + ']"]');
747+
if (fileInput[0] && fileInput[0].files) {
748+
var file = fileInput[0].files[0];
749+
if (file) {
750+
formData.append(parameter.name, file, file.name);
751+
}
750752
}
753+
return;
751754
}
755+
756+
formData.append(parameter.name,
757+
$scope.requestModel.parameters[parameter.name]);
752758
});
753759
return formData;
754760
}
@@ -785,7 +791,7 @@ SwaggerEditor.controller('TryOperation', function($scope, formdataFilter,
785791
var omitHeaders = ['Host', 'Accept-Encoding', 'Connection', 'Origin',
786792
'Referer', 'User-Agent', 'Cache-Control', 'Content-Length'];
787793

788-
var headers = _.omit($scope.getHeaders(), omitHeaders);
794+
var headers = _.omit($scope.getHeaders(), omitHeaders);
789795
if (hasFileParam()) {
790796
delete headers['Content-Type'];
791797
}
@@ -835,7 +841,7 @@ SwaggerEditor.controller('TryOperation', function($scope, formdataFilter,
835841
// Try if it's JSON and return pretty JSON
836842
try {
837843
return JSON.stringify(JSON.parse(input), null, 2);
838-
} catch (jsonError) {}
844+
} catch (jsonError) {} // eslint-disable-line no-empty
839845

840846
return input;
841847
};

scripts/services/builder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SwaggerEditor.service('Builder', function Builder(SwayWorker, Preferences) {
1616
var json;
1717

1818
return new Promise(function(resolve, reject) {
19-
// If stringVlue is empty, return emptyDocsError
19+
// If stringValue is empty, return emptyDocsError
2020
if (!stringValue) {
2121
reject({
2222
specs: null,

spec-files/twitter.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@ paths:
205205
type: array
206206
items:
207207
$ref: '#/definitions/Tweets'
208+
post:
209+
description: Retweens a tweet
210+
security:
211+
- oauth:
212+
- basic
213+
parameters:
214+
- name: id
215+
in: path
216+
description: The numerical ID of the desired status
217+
required: true
218+
type: string
219+
- name: trim_user
220+
in: query
221+
description: When set to either true, t or 1, each tweet returned in a timeline will include a user object
222+
required: false
223+
type: string
224+
responses:
225+
"200":
226+
description: Success
227+
schema:
228+
$ref: '#/definitions/Tweets'
208229

209230
/statuses/show/{id}:
210231
get:
@@ -312,28 +333,7 @@ paths:
312333
"403":
313334
description: Error
314335

315-
/statuses/retweets/{id}:
316-
post:
317-
description: Retweens a tweet
318-
security:
319-
- oauth:
320-
- basic
321-
parameters:
322-
- name: id
323-
in: path
324-
description: The numerical ID of the desired status
325-
required: true
326-
type: string
327-
- name: trim_user
328-
in: query
329-
description: When set to either true, t or 1, each tweet returned in a timeline will include a user object
330-
required: false
331-
type: string
332-
responses:
333-
"200":
334-
description: Success
335-
schema:
336-
$ref: '#/definitions/Tweets'
336+
337337

338338
/statuses/oembed:
339339
get:

test/e2e/protractor.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ var config = {
1717
return console.error(err);
1818
}
1919

20-
console.log('Test server started at http://localhost:' + PORT);
20+
console.log('Test server started at http://127.0.0.1:' + PORT);
2121
});
2222
},
2323

24-
baseUrl: 'http://localhost:' + PORT + '/',
24+
baseUrl: 'http://127.0.0.1:' + PORT + '/',
2525

2626
directConnect: true,
2727

test/unit/spec/controllers/tryoperation/makeCall.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,13 @@ describe('Controller: TryOperation', function() {
1313
$controller = _$controller_;
1414
scope.operation = {};
1515
scope.specs = {};
16-
scope.getParameters = function mockGetParameters() {
17-
return [];
18-
};
19-
scope.$watch = function() {};
20-
$controller('TryOperation', {
21-
$scope: scope
22-
});
2316
}));
2417

2518
describe('$scope.makeCall', function() {
26-
afterEach(function () {
19+
afterEach(function() {
2720
$.ajax.restore();
2821
});
29-
22+
3023
it('should call ajax when it\'s called', function() {
3124
var operation = {
3225
responses: {
@@ -47,9 +40,17 @@ describe('Controller: TryOperation', function() {
4740
}
4841
}
4942
};
43+
scope.getParameters = function mockGetParameters() {
44+
return [];
45+
};
5046
scope.pathName = '/';
5147
scope.operation = operation;
5248

49+
scope.$watch = function() {};
50+
$controller('TryOperation', {
51+
$scope: scope
52+
});
53+
5354
var ajaxStub = sinon.stub($, 'ajax').returns({
5455
fail: function() {
5556
return {done: function() {}};
@@ -64,14 +65,12 @@ describe('Controller: TryOperation', function() {
6465
describe('use server', function() {
6566

6667
it('should upload the file', function() {
67-
var parameters= [{
68-
name: 'upload',
69-
in: 'formData',
70-
required: true,
71-
schema: {
72-
type: 'file'
73-
}
74-
}];
68+
var parameters = [{
69+
name: 'upload',
70+
in: 'formData',
71+
required: true,
72+
type: 'file'
73+
}];
7574
scope.specs = {
7675
host: 'localhost:3000',
7776
swagger: '2.0',
@@ -80,7 +79,7 @@ describe('Controller: TryOperation', function() {
8079
title: 'Upload API'
8180
},
8281
security: [],
83-
consumes: [ 'multipart/form-data' ],
82+
consumes: ['multipart/form-data'],
8483
paths: {
8584
'/': {
8685
post: {
@@ -94,7 +93,9 @@ describe('Controller: TryOperation', function() {
9493
}
9594
}
9695
};
97-
scope.pathName = '/';
96+
scope.operationName = 'post';
97+
scope.pathName = '/upload';
98+
9899
scope.getParameters = function() {
99100
return [{
100101
name: 'upload',
@@ -106,20 +107,17 @@ describe('Controller: TryOperation', function() {
106107
}
107108
}];
108109
};
109-
110+
scope.$watch = function() {};
111+
$controller('TryOperation', {
112+
$scope: scope
113+
});
110114
scope.getHeaderParams = {};
111-
scope.specs.host = '127.0.0.1:8080';
112-
var header = scope.getHeaders();
113-
114-
scope.requestModel = {
115-
scheme: "http",
116-
accept: "*/*",
117-
contentType: "multipart/form-data",
118-
parameters: {
119-
upload: './file.txt'
120-
}
121-
};
122-
var data = scope.getRequestBody()
115+
scope.specs.host = 'localhost:3000';
116+
sinon.stub(scope, 'getHeaders').returns({
117+
'Accept': "*/*",
118+
'Content-Type': 'multipart/form-data'
119+
});
120+
sinon.stub(scope, 'getRequestBody').returns({mydata: 12});
123121

124122
sinon.stub($, "ajax").returns({
125123
fail: function() {
@@ -129,14 +127,16 @@ describe('Controller: TryOperation', function() {
129127

130128
scope.makeCall();
131129

132-
expect($.ajax.calledWithMatch({
130+
$.ajax.should.have.been.calledWithMatch({
133131
url: 'http://localhost:3000/upload',
134132
type: 'post',
135-
headers: header,
136-
data: data,
137-
contentType: false,
133+
headers: {
134+
'Accept': '*/*',
135+
'Content-Type': undefined
136+
},
137+
data: {mydata: 12},
138138
processData: false
139-
}));
139+
});
140140
});
141141
});
142142

0 commit comments

Comments
 (0)