diff --git a/samples/client/petstore-security-test/javascript-closure-angular/API/Client/FakeApi.js b/samples/client/petstore-security-test/javascript-closure-angular/API/Client/FakeApi.js index 231c9f0308..061532b28b 100644 --- a/samples/client/petstore-security-test/javascript-closure-angular/API/Client/FakeApi.js +++ b/samples/client/petstore-security-test/javascript-closure-angular/API/Client/FakeApi.js @@ -3,14 +3,13 @@ * Do not edit this file by hand or your changes will be lost next time it is * generated. * - * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end - * Version: 1.0.0 ' \" =end - * Generated at: 2016-06-29T22:04:03.401+08:00 - * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * Version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Generated by: io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** - * @license Apache 2.0 ' \" =end - * http://www.apache.org/licenses/LICENSE-2.0.html ' \" =end + * @license Apache 2.0 *_/ ' \" =end -- \\r\\n \\n \\r + * http://www.apache.org/licenses/LICENSE-2.0.html *_/ ' \" =end -- \\r\\n \\n \\r */ goog.provide('API.Client.FakeApi'); @@ -27,7 +26,7 @@ API.Client.FakeApi = function($http, $httpParamSerializer, $injector) { /** @private {!string} */ this.basePath_ = $injector.has('FakeApiBasePath') ? /** @type {!string} */ ($injector.get('FakeApiBasePath')) : - 'https://petstore.swagger.io ' \" =end/v2 ' \" =end'; + 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'; /** @private {!Object} */ this.defaultHeaders_ = $injector.has('FakeApiDefaultHeaders') ? @@ -44,13 +43,13 @@ API.Client.FakeApi = function($http, $httpParamSerializer, $injector) { API.Client.FakeApi.$inject = ['$http', '$httpParamSerializer', '$injector']; /** - * To test code injection ' \" =end + * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param {!string=} opt_testCodeInjectEnd To test code injection ' \" =end + * @param {!string=} opt_testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ -API.Client.FakeApi.prototype.testCodeInjectEnd = function(opt_testCodeInjectEnd, opt_extraHttpRequestParams) { +API.Client.FakeApi.prototype.testCodeInjectEndRnNR = function(opt_testCodeInjectEndRnNR, opt_extraHttpRequestParams) { /** @const {string} */ var path = this.basePath_ + '/fake'; @@ -64,7 +63,7 @@ API.Client.FakeApi.prototype.testCodeInjectEnd = function(opt_testCodeInjectEnd, headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; - formParams['test code inject */ ' " =end'] = opt_testCodeInjectEnd; + formParams['test code inject */ ' " =end -- \r\n \n \r'] = opt_testCodeInjectEndRnNR; /** @type {!Object} */ var httpRequestParams = { diff --git a/samples/client/petstore-security-test/javascript-closure-angular/API/Client/ModelReturn.js b/samples/client/petstore-security-test/javascript-closure-angular/API/Client/ModelReturn.js index 982a02d494..bfc1c02f01 100644 --- a/samples/client/petstore-security-test/javascript-closure-angular/API/Client/ModelReturn.js +++ b/samples/client/petstore-security-test/javascript-closure-angular/API/Client/ModelReturn.js @@ -1,13 +1,13 @@ goog.provide('API.Client.Return'); /** - * Model for testing reserved words ' \" =end + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r * @record */ API.Client.ModelReturn = function() {} /** - * property description ' \" =end + * property description *_/ ' \" =end -- \\r\\n \\n \\r * @type {!number} * @export */ diff --git a/samples/client/petstore-security-test/javascript/README.md b/samples/client/petstore-security-test/javascript/README.md index f49c8f9d42..144c7dbfd5 100644 --- a/samples/client/petstore-security-test/javascript/README.md +++ b/samples/client/petstore-security-test/javascript/README.md @@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r - Package version: 1.0.0 *_/ =end -- \r\n \n \r -- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen +- Build package: io.swagger.codegen.languages.JavascriptClientCodegen ## Installation diff --git a/samples/client/petstore-security-test/javascript/package.json b/samples/client/petstore-security-test/javascript/package.json index 89f2c51c2c..f0e7cd7749 100644 --- a/samples/client/petstore-security-test/javascript/package.json +++ b/samples/client/petstore-security-test/javascript/package.json @@ -2,13 +2,13 @@ "name": "swagger_petstore____end____rn_n_r", "version": "1.0.0 *_/ =end -- \r\n \n \r", "description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters_______end______", - "license": "Apache-2.0", + "license": "Unlicense", "main": "src/index.js", "scripts": { "test": "./node_modules/mocha/bin/mocha --recursive" }, "dependencies": { - "superagent": "1.7.1" + "superagent": "3.5.2" }, "devDependencies": { "mocha": "~2.3.4", diff --git a/samples/client/petstore-security-test/javascript/src/ApiClient.js b/samples/client/petstore-security-test/javascript/src/ApiClient.js index 20e0bc173f..46cb2e31e7 100644 --- a/samples/client/petstore-security-test/javascript/src/ApiClient.js +++ b/samples/client/petstore-security-test/javascript/src/ApiClient.js @@ -9,34 +9,23 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['superagent'], factory); + define(['superagent', 'querystring'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('superagent')); + module.exports = factory(require('superagent'), require('querystring')); } else { // Browser globals (root is window) if (!root.SwaggerPetstoreEndRnNR) { root.SwaggerPetstoreEndRnNR = {}; } - root.SwaggerPetstoreEndRnNR.ApiClient = factory(root.superagent); + root.SwaggerPetstoreEndRnNR.ApiClient = factory(root.superagent, root.querystring); } -}(this, function(superagent) { +}(this, function(superagent, querystring) { 'use strict'; /** @@ -55,9 +44,9 @@ /** * The base URL against which to resolve every API call's (relative) path. * @type {String} - * @default https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r + * @default https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r */ - this.basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'.replace(/\/+$/, ''); + this.basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'.replace(/\/+$/, ''); /** * The authentication methods to be included for all API calls. @@ -80,6 +69,30 @@ * @default 60000 */ this.timeout = 60000; + + /** + * If set to false an additional timestamp parameter is added to all API GET calls to + * prevent browser caching + * @type {Boolean} + * @default true + */ + this.cache = true; + + /** + * If set to true, the client will save the cookies from each server + * response, and return them in the next request. + * @default false + */ + this.enableCookies = false; + + /* + * Used to save and return cookies in a node.js (non-browser) setting, + * if this.enableCookies is set to true. + */ + if (typeof window === 'undefined') { + this.agent = new superagent.agent(); + } + }; /** @@ -316,13 +329,13 @@ * @returns A value of the specified type. */ exports.prototype.deserialize = function deserialize(response, returnType) { - if (response == null || returnType == null) { + if (response == null || returnType == null || response.status == 204) { return null; } // Rely on SuperAgent for parsing response body. // See http://visionmedia.github.io/superagent/#parsing-response-bodies var data = response.body; - if (data == null) { + if (data == null || (typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length)) { // SuperAgent does not always produce a body; use the unparsed response as a fallback data = response.text; } @@ -366,6 +379,9 @@ this.applyAuthToRequest(request, authNames); // set query parameters + if (httpMethod.toUpperCase() === 'GET' && this.cache === false) { + queryParams['_'] = new Date().getTime(); + } request.query(this.normalizeParams(queryParams)); // set header parameters @@ -385,7 +401,7 @@ } if (contentType === 'application/x-www-form-urlencoded') { - request.send(this.normalizeParams(formParams)); + request.send(querystring.stringify(this.normalizeParams(formParams))); } else if (contentType == 'multipart/form-data') { var _formParams = this.normalizeParams(formParams); for (var key in _formParams) { @@ -407,12 +423,33 @@ request.accept(accept); } + if (returnType === 'Blob') { + request.responseType('blob'); + } + + // Attach previously saved cookies, if enabled + if (this.enableCookies){ + if (typeof window === 'undefined') { + this.agent.attachCookies(request); + } + else { + request.withCredentials(); + } + } + request.end(function(error, response) { if (callback) { var data = null; if (!error) { - data = _this.deserialize(response, returnType); + try { + data = _this.deserialize(response, returnType); + if (_this.enableCookies && typeof window === 'undefined'){ + _this.agent.saveCookies(response); + } + } catch (err) { + error = err; + } } callback(error, data, response); } @@ -437,9 +474,12 @@ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: * all properties on data will be converted to this type. - * @returns An instance of the specified type. + * @returns An instance of the specified type or null or undefined if data is null or undefined. */ exports.convertToType = function(data, type) { + if (data === null || data === undefined) + return data + switch (type) { case 'Boolean': return Boolean(data); @@ -451,6 +491,8 @@ return String(data); case 'Date': return this.parseDate(String(data)); + case 'Blob': + return data; default: if (type === Object) { // generic object, return directly diff --git a/samples/client/petstore-security-test/javascript/src/api/FakeApi.js b/samples/client/petstore-security-test/javascript/src/api/FakeApi.js index f7585314e6..ce404353b3 100644 --- a/samples/client/petstore-security-test/javascript/src/api/FakeApi.js +++ b/samples/client/petstore-security-test/javascript/src/api/FakeApi.js @@ -9,17 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ (function(root, factory) { diff --git a/samples/client/petstore-security-test/javascript/src/index.js b/samples/client/petstore-security-test/javascript/src/index.js index 3a2295732e..03dc50ff27 100644 --- a/samples/client/petstore-security-test/javascript/src/index.js +++ b/samples/client/petstore-security-test/javascript/src/index.js @@ -9,17 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ (function(factory) { diff --git a/samples/client/petstore-security-test/javascript/src/model/ModelReturn.js b/samples/client/petstore-security-test/javascript/src/model/ModelReturn.js index 7803d3622c..c6961f5673 100644 --- a/samples/client/petstore-security-test/javascript/src/model/ModelReturn.js +++ b/samples/client/petstore-security-test/javascript/src/model/ModelReturn.js @@ -9,17 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ (function(root, factory) {