} body List of user object
*/
- this.createUsersWithListInput = function(opts) {
- opts = opts || {};
- var postBody = opts['body'];
+ this.createUsersWithListInput = function(body) {
+ var postBody = body;
+
+ // verify the required parameter 'body' is set
+ if (body == undefined || body == null) {
+ throw "Missing the required parameter 'body' when calling createUsersWithListInput";
+ }
var pathParams = {
@@ -121,7 +130,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -158,7 +167,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -196,7 +205,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = User;
return this.apiClient.callApi(
@@ -210,21 +219,29 @@
/**
* Logs user into the system
*
- * @param {Object} opts Optional parameters
- * @param {String} opts.username The user name for login
- * @param {String} opts.password The password for login in clear text
+ * @param {String} username The user name for login
+ * @param {String} password The password for login in clear text
* data is of type: {'String'}
*/
- this.loginUser = function(opts) {
- opts = opts || {};
+ this.loginUser = function(username, password) {
var postBody = null;
+ // verify the required parameter 'username' is set
+ if (username == undefined || username == null) {
+ throw "Missing the required parameter 'username' when calling loginUser";
+ }
+
+ // verify the required parameter 'password' is set
+ if (password == undefined || password == null) {
+ throw "Missing the required parameter 'password' when calling loginUser";
+ }
+
var pathParams = {
};
var queryParams = {
- 'username': opts['username'],
- 'password': opts['password']
+ 'username': username,
+ 'password': password
};
var headerParams = {
};
@@ -233,7 +250,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = 'String';
return this.apiClient.callApi(
@@ -263,7 +280,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
@@ -278,18 +295,21 @@
* Updated user
* This can only be done by the logged in user.
* @param {String} username name that need to be deleted
- * @param {Object} opts Optional parameters
- * @param {module:model/User} opts.body Updated user object
+ * @param {module:model/User} body Updated user object
*/
- this.updateUser = function(username, opts) {
- opts = opts || {};
- var postBody = opts['body'];
+ this.updateUser = function(username, body) {
+ var postBody = body;
// verify the required parameter 'username' is set
if (username == undefined || username == null) {
throw "Missing the required parameter 'username' when calling updateUser";
}
+ // verify the required parameter 'body' is set
+ if (body == undefined || body == null) {
+ throw "Missing the required parameter 'body' when calling updateUser";
+ }
+
var pathParams = {
'username': username
@@ -303,7 +323,7 @@
var authNames = [];
var contentTypes = [];
- var accepts = ['application/json', 'application/xml'];
+ var accepts = ['application/xml', 'application/json'];
var returnType = null;
return this.apiClient.callApi(
diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js
index b0d17b3ef3a..727b4782f45 100644
--- a/samples/client/petstore/javascript-promise/src/index.js
+++ b/samples/client/petstore/javascript-promise/src/index.js
@@ -1,16 +1,16 @@
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['ApiClient', 'model/Category', 'model/Order', 'model/Pet', 'model/Tag', 'model/User', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
+ define(['ApiClient', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('./ApiClient'), require('./model/Category'), require('./model/Order'), require('./model/Pet'), require('./model/Tag'), require('./model/User'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
+ module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
}
-}(function(ApiClient, Category, Order, Pet, Tag, User, PetApi, StoreApi, UserApi) {
+}(function(ApiClient, Animal, AnimalFarm, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) {
'use strict';
/**
- * This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters.
+ * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose..
* The index
module provides access to constructors for all the classes which comprise the public API.
*
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
@@ -46,11 +46,66 @@
* @property {module:ApiClient}
*/
ApiClient: ApiClient,
+ /**
+ * The Animal model constructor.
+ * @property {module:model/Animal}
+ */
+ Animal: Animal,
+ /**
+ * The AnimalFarm model constructor.
+ * @property {module:model/AnimalFarm}
+ */
+ AnimalFarm: AnimalFarm,
+ /**
+ * The ApiResponse model constructor.
+ * @property {module:model/ApiResponse}
+ */
+ ApiResponse: ApiResponse,
+ /**
+ * The Cat model constructor.
+ * @property {module:model/Cat}
+ */
+ Cat: Cat,
/**
* The Category model constructor.
* @property {module:model/Category}
*/
Category: Category,
+ /**
+ * The Dog model constructor.
+ * @property {module:model/Dog}
+ */
+ Dog: Dog,
+ /**
+ * The EnumClass model constructor.
+ * @property {module:model/EnumClass}
+ */
+ EnumClass: EnumClass,
+ /**
+ * The EnumTest model constructor.
+ * @property {module:model/EnumTest}
+ */
+ EnumTest: EnumTest,
+ /**
+ * The FormatTest model constructor.
+ * @property {module:model/FormatTest}
+ */
+ FormatTest: FormatTest,
+ /**
+ * The Model200Response model constructor.
+ * @property {module:model/Model200Response}
+ */
+ Model200Response: Model200Response,
+ /**
+ * The ModelReturn model constructor.
+ * @property {module:model/ModelReturn}
+ */
+ ModelReturn: ModelReturn,
+ /**
+ * The Name model constructor.
+ * @property {module:model/Name}
+ */
+ Name: Name,
/**
* The Order model constructor.
* @property {module:model/Order}
@@ -61,6 +116,11 @@
* @property {module:model/Pet}
*/
Pet: Pet,
+ /**
+ * The SpecialModelName model constructor.
+ * @property {module:model/SpecialModelName}
+ */
+ SpecialModelName: SpecialModelName,
/**
* The Tag model constructor.
* @property {module:model/Tag}
@@ -71,6 +131,11 @@
* @property {module:model/User}
*/
User: User,
+ /**
+ * The FakeApi service constructor.
+ * @property {module:api/FakeApi}
+ */
+ FakeApi: FakeApi,
/**
* The PetApi service constructor.
* @property {module:api/PetApi}
diff --git a/samples/client/petstore/javascript-promise/src/model/Animal.js b/samples/client/petstore/javascript-promise/src/model/Animal.js
index 674471a30ee..e42874c669b 100644
--- a/samples/client/petstore/javascript-promise/src/model/Animal.js
+++ b/samples/client/petstore/javascript-promise/src/model/Animal.js
@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['../ApiClient'], factory);
+ define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Animal model module.
* @module model/Animal
@@ -28,8 +31,9 @@
* @param className
*/
var exports = function(className) {
+ var _this = this;
- this['className'] = className;
+ _this['className'] = className;
};
/**
@@ -40,7 +44,7 @@
* @return {module:model/Animal} The populated Animal
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('className')) {
@@ -50,7 +54,6 @@
return obj;
}
-
/**
* @member {String} className
*/
@@ -61,3 +64,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js
new file mode 100644
index 00000000000..d5f6aa2a424
--- /dev/null
+++ b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js
@@ -0,0 +1,64 @@
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['ApiClient', 'model/Animal'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ module.exports = factory(require('../ApiClient'), require('./Animal'));
+ } else {
+ // Browser globals (root is window)
+ if (!root.SwaggerPetstore) {
+ root.SwaggerPetstore = {};
+ }
+ root.SwaggerPetstore.AnimalFarm = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal);
+ }
+}(this, function(ApiClient, Animal) {
+ 'use strict';
+
+
+
+
+ /**
+ * The AnimalFarm model module.
+ * @module model/AnimalFarm
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new AnimalFarm
.
+ * @alias module:model/AnimalFarm
+ * @class
+ * @extends Array
+ */
+ var exports = function() {
+ var _this = this;
+ _this = new Array();
+ Object.setPrototypeOf(_this, exports);
+
+ return _this;
+ };
+
+ /**
+ * Constructs a AnimalFarm
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/AnimalFarm} obj Optional instance to populate.
+ * @return {module:model/AnimalFarm} The populated AnimalFarm
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+ ApiClient.constructFromObject(data, obj, Animal);
+
+ }
+ return obj;
+ }
+
+
+
+
+
+ return exports;
+}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js
new file mode 100644
index 00000000000..6d4c970264b
--- /dev/null
+++ b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js
@@ -0,0 +1,83 @@
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['ApiClient'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ module.exports = factory(require('../ApiClient'));
+ } else {
+ // Browser globals (root is window)
+ if (!root.SwaggerPetstore) {
+ root.SwaggerPetstore = {};
+ }
+ root.SwaggerPetstore.ApiResponse = factory(root.SwaggerPetstore.ApiClient);
+ }
+}(this, function(ApiClient) {
+ 'use strict';
+
+
+
+
+ /**
+ * The ApiResponse model module.
+ * @module model/ApiResponse
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new ApiResponse
.
+ * @alias module:model/ApiResponse
+ * @class
+ */
+ var exports = function() {
+ var _this = this;
+
+
+
+
+ };
+
+ /**
+ * Constructs a ApiResponse
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/ApiResponse} obj Optional instance to populate.
+ * @return {module:model/ApiResponse} The populated ApiResponse
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('code')) {
+ obj['code'] = ApiClient.convertToType(data['code'], 'Integer');
+ }
+ if (data.hasOwnProperty('type')) {
+ obj['type'] = ApiClient.convertToType(data['type'], 'String');
+ }
+ if (data.hasOwnProperty('message')) {
+ obj['message'] = ApiClient.convertToType(data['message'], 'String');
+ }
+ }
+ return obj;
+ }
+
+ /**
+ * @member {Integer} code
+ */
+ exports.prototype['code'] = undefined;
+ /**
+ * @member {String} type
+ */
+ exports.prototype['type'] = undefined;
+ /**
+ * @member {String} message
+ */
+ exports.prototype['message'] = undefined;
+
+
+
+
+ return exports;
+}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Cat.js b/samples/client/petstore/javascript-promise/src/model/Cat.js
index c878af6edec..a6b25bc6d58 100644
--- a/samples/client/petstore/javascript-promise/src/model/Cat.js
+++ b/samples/client/petstore/javascript-promise/src/model/Cat.js
@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['../ApiClient', './Animal'], factory);
+ define(['ApiClient', 'model/Animal'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./Animal'));
@@ -15,6 +15,9 @@
}(this, function(ApiClient, Animal) {
'use strict';
+
+
+
/**
* The Cat model module.
* @module model/Cat
@@ -29,7 +32,8 @@
* @param className
*/
var exports = function(className) {
- Animal.call(this, className);
+ var _this = this;
+ Animal.call(_this, className);
};
@@ -41,7 +45,7 @@
* @return {module:model/Cat} The populated Cat
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
Animal.constructFromObject(data, obj);
if (data.hasOwnProperty('declawed')) {
@@ -54,7 +58,6 @@
exports.prototype = Object.create(Animal.prototype);
exports.prototype.constructor = exports;
-
/**
* @member {Boolean} declawed
*/
@@ -65,3 +68,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js
index 9956525e037..9e2e19ac5bb 100644
--- a/samples/client/petstore/javascript-promise/src/model/Category.js
+++ b/samples/client/petstore/javascript-promise/src/model/Category.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Category model module.
* @module model/Category
@@ -54,12 +57,10 @@
return obj;
}
-
/**
* @member {Integer} id
*/
exports.prototype['id'] = undefined;
-
/**
* @member {String} name
*/
@@ -70,3 +71,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Dog.js b/samples/client/petstore/javascript-promise/src/model/Dog.js
index e5e55581a70..ee17ae3467f 100644
--- a/samples/client/petstore/javascript-promise/src/model/Dog.js
+++ b/samples/client/petstore/javascript-promise/src/model/Dog.js
@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['../ApiClient', './Animal'], factory);
+ define(['ApiClient', 'model/Animal'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./Animal'));
@@ -15,6 +15,9 @@
}(this, function(ApiClient, Animal) {
'use strict';
+
+
+
/**
* The Dog model module.
* @module model/Dog
@@ -29,7 +32,8 @@
* @param className
*/
var exports = function(className) {
- Animal.call(this, className);
+ var _this = this;
+ Animal.call(_this, className);
};
@@ -41,7 +45,7 @@
* @return {module:model/Dog} The populated Dog
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
Animal.constructFromObject(data, obj);
if (data.hasOwnProperty('breed')) {
@@ -54,7 +58,6 @@
exports.prototype = Object.create(Animal.prototype);
exports.prototype.constructor = exports;
-
/**
* @member {String} breed
*/
@@ -65,3 +68,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/EnumClass.js b/samples/client/petstore/javascript-promise/src/model/EnumClass.js
new file mode 100644
index 00000000000..e9bf5219ee5
--- /dev/null
+++ b/samples/client/petstore/javascript-promise/src/model/EnumClass.js
@@ -0,0 +1,44 @@
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['ApiClient'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ module.exports = factory(require('../ApiClient'));
+ } else {
+ // Browser globals (root is window)
+ if (!root.SwaggerPetstore) {
+ root.SwaggerPetstore = {};
+ }
+ root.SwaggerPetstore.EnumClass = factory(root.SwaggerPetstore.ApiClient);
+ }
+}(this, function(ApiClient) {
+ 'use strict';
+
+
+ /**
+ * Enum class EnumClass.
+ * @enum {}
+ * @readonly
+ */
+ var exports = {
+ /**
+ * value: "_abc"
+ * @const
+ */
+ "_abc": "_abc",
+ /**
+ * value: "-efg"
+ * @const
+ */
+ "-efg": "-efg",
+ /**
+ * value: "(xyz)"
+ * @const
+ */
+ "(xyz)": "(xyz)" };
+
+ return exports;
+}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/EnumTest.js b/samples/client/petstore/javascript-promise/src/model/EnumTest.js
new file mode 100644
index 00000000000..6f8f0de3836
--- /dev/null
+++ b/samples/client/petstore/javascript-promise/src/model/EnumTest.js
@@ -0,0 +1,131 @@
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['ApiClient'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ module.exports = factory(require('../ApiClient'));
+ } else {
+ // Browser globals (root is window)
+ if (!root.SwaggerPetstore) {
+ root.SwaggerPetstore = {};
+ }
+ root.SwaggerPetstore.EnumTest = factory(root.SwaggerPetstore.ApiClient);
+ }
+}(this, function(ApiClient) {
+ 'use strict';
+
+
+
+
+ /**
+ * The EnumTest model module.
+ * @module model/EnumTest
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new EnumTest
.
+ * @alias module:model/EnumTest
+ * @class
+ */
+ var exports = function() {
+ var _this = this;
+
+
+
+
+ };
+
+ /**
+ * Constructs a EnumTest
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/EnumTest} obj Optional instance to populate.
+ * @return {module:model/EnumTest} The populated EnumTest
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+
+ if (data.hasOwnProperty('enum_string')) {
+ obj['enum_string'] = ApiClient.convertToType(data['enum_string'], 'String');
+ }
+ if (data.hasOwnProperty('enum_integer')) {
+ obj['enum_integer'] = ApiClient.convertToType(data['enum_integer'], 'Integer');
+ }
+ if (data.hasOwnProperty('enum_number')) {
+ obj['enum_number'] = ApiClient.convertToType(data['enum_number'], 'Number');
+ }
+ }
+ return obj;
+ }
+
+ /**
+ * @member {module:model/EnumTest.EnumStringEnum} enum_string
+ */
+ exports.prototype['enum_string'] = undefined;
+ /**
+ * @member {module:model/EnumTest.EnumIntegerEnum} enum_integer
+ */
+ exports.prototype['enum_integer'] = undefined;
+ /**
+ * @member {module:model/EnumTest.EnumNumberEnum} enum_number
+ */
+ exports.prototype['enum_number'] = undefined;
+
+
+ /**
+ * Allowed values for the enum_string
property.
+ * @enum {String}
+ * @readonly
+ */
+ exports.EnumStringEnum = {
+ /**
+ * value: "UPPER"
+ * @const
+ */
+ "UPPER": "UPPER",
+ /**
+ * value: "lower"
+ * @const
+ */
+ "lower": "lower" };
+ /**
+ * Allowed values for the enum_integer
property.
+ * @enum {Integer}
+ * @readonly
+ */
+ exports.EnumIntegerEnum = {
+ /**
+ * value: 1
+ * @const
+ */
+ "1": 1,
+ /**
+ * value: -1
+ * @const
+ */
+ "-1": -1 };
+ /**
+ * Allowed values for the enum_number
property.
+ * @enum {Number}
+ * @readonly
+ */
+ exports.EnumNumberEnum = {
+ /**
+ * value: 1.1
+ * @const
+ */
+ "1.1": 1.1,
+ /**
+ * value: -1.2
+ * @const
+ */
+ "-1.2": -1.2 };
+
+
+ return exports;
+}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/FormatTest.js b/samples/client/petstore/javascript-promise/src/model/FormatTest.js
index 46a9bc854fc..ed9e0cfcaf8 100644
--- a/samples/client/petstore/javascript-promise/src/model/FormatTest.js
+++ b/samples/client/petstore/javascript-promise/src/model/FormatTest.js
@@ -1,7 +1,7 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['../ApiClient'], factory);
+ define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The FormatTest model module.
* @module model/FormatTest
@@ -26,20 +29,26 @@
* @alias module:model/FormatTest
* @class
* @param _number
+ * @param _byte
+ * @param _date
+ * @param password
*/
- var exports = function(_number) {
+ var exports = function(_number, _byte, _date, password) {
+ var _this = this;
- this['number'] = _number;
-
-
+ _this['number'] = _number;
+ _this['byte'] = _byte;
+
+ _this['date'] = _date;
+ _this['password'] = password;
};
/**
@@ -50,7 +59,7 @@
* @return {module:model/FormatTest} The populated FormatTest
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('integer')) {
@@ -84,70 +93,75 @@
obj['date'] = ApiClient.convertToType(data['date'], 'Date');
}
if (data.hasOwnProperty('dateTime')) {
- obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'String');
+ obj['dateTime'] = ApiClient.convertToType(data['dateTime'], 'Date');
+ }
+ if (data.hasOwnProperty('uuid')) {
+ obj['uuid'] = ApiClient.convertToType(data['uuid'], 'String');
+ }
+ if (data.hasOwnProperty('password')) {
+ obj['password'] = ApiClient.convertToType(data['password'], 'String');
}
}
return obj;
}
-
/**
* @member {Integer} integer
*/
exports.prototype['integer'] = undefined;
-
/**
* @member {Integer} int32
*/
exports.prototype['int32'] = undefined;
-
/**
* @member {Integer} int64
*/
exports.prototype['int64'] = undefined;
-
/**
* @member {Number} number
*/
exports.prototype['number'] = undefined;
-
/**
* @member {Number} float
*/
exports.prototype['float'] = undefined;
-
/**
* @member {Number} double
*/
exports.prototype['double'] = undefined;
-
/**
* @member {String} string
*/
exports.prototype['string'] = undefined;
-
/**
* @member {String} byte
*/
exports.prototype['byte'] = undefined;
-
/**
* @member {String} binary
*/
exports.prototype['binary'] = undefined;
-
/**
* @member {Date} date
*/
exports.prototype['date'] = undefined;
-
/**
- * @member {String} dateTime
+ * @member {Date} dateTime
*/
exports.prototype['dateTime'] = undefined;
+ /**
+ * @member {String} uuid
+ */
+ exports.prototype['uuid'] = undefined;
+ /**
+ * @member {String} password
+ */
+ exports.prototype['password'] = undefined;
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js b/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js
deleted file mode 100644
index f2abaf1bd1b..00000000000
--- a/samples/client/petstore/javascript-promise/src/model/InlineResponse200.js
+++ /dev/null
@@ -1,132 +0,0 @@
-(function(root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['ApiClient', 'model/Tag'], factory);
- } else if (typeof module === 'object' && module.exports) {
- // CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('../ApiClient'), require('./Tag'));
- } else {
- // Browser globals (root is window)
- if (!root.SwaggerPetstore) {
- root.SwaggerPetstore = {};
- }
- root.SwaggerPetstore.InlineResponse200 = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Tag);
- }
-}(this, function(ApiClient, Tag) {
- 'use strict';
-
- /**
- * The InlineResponse200 model module.
- * @module model/InlineResponse200
- * @version 1.0.0
- */
-
- /**
- * Constructs a new InlineResponse200
.
- * @alias module:model/InlineResponse200
- * @class
- * @param id
- */
- var exports = function(id) {
-
-
- this['id'] = id;
-
-
-
-
- };
-
- /**
- * Constructs a InlineResponse200
from a plain JavaScript object, optionally creating a new instance.
- * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
- * @param {Object} data The plain JavaScript object bearing properties of interest.
- * @param {module:model/InlineResponse200} obj Optional instance to populate.
- * @return {module:model/InlineResponse200} The populated InlineResponse200
instance.
- */
- exports.constructFromObject = function(data, obj) {
- if (data) {
- obj = obj || new exports();
-
- if (data.hasOwnProperty('tags')) {
- obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
- if (data.hasOwnProperty('id')) {
- obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
- if (data.hasOwnProperty('category')) {
- obj['category'] = ApiClient.convertToType(data['category'], Object);
- }
- if (data.hasOwnProperty('status')) {
- obj['status'] = ApiClient.convertToType(data['status'], 'String');
- }
- if (data.hasOwnProperty('name')) {
- obj['name'] = ApiClient.convertToType(data['name'], 'String');
- }
- if (data.hasOwnProperty('photoUrls')) {
- obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
- }
- return obj;
- }
-
-
- /**
- * @member {Array.} tags
- */
- exports.prototype['tags'] = undefined;
-
- /**
- * @member {Integer} id
- */
- exports.prototype['id'] = undefined;
-
- /**
- * @member {Object} category
- */
- exports.prototype['category'] = undefined;
-
- /**
- * pet status in the store
- * @member {module:model/InlineResponse200.StatusEnum} status
- */
- exports.prototype['status'] = undefined;
-
- /**
- * @member {String} name
- */
- exports.prototype['name'] = undefined;
-
- /**
- * @member {Array.} photoUrls
- */
- exports.prototype['photoUrls'] = undefined;
-
-
- /**
- * Allowed values for the status
property.
- * @enum {String}
- * @readonly
- */
- exports.StatusEnum = {
- /**
- * value: available
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * value: pending
- * @const
- */
- PENDING: "pending",
-
- /**
- * value: sold
- * @const
- */
- SOLD: "sold"
- };
-
- return exports;
-}));
diff --git a/samples/client/petstore/javascript-promise/src/model/Model200Response.js b/samples/client/petstore/javascript-promise/src/model/Model200Response.js
index 8381185d9d0..1d83d420287 100644
--- a/samples/client/petstore/javascript-promise/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript-promise/src/model/Model200Response.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Model200Response model module.
* @module model/Model200Response
@@ -28,6 +31,7 @@
* @class
*/
var exports = function() {
+ var _this = this;
};
@@ -40,7 +44,7 @@
* @return {module:model/Model200Response} The populated Model200Response
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('name')) {
@@ -50,7 +54,6 @@
return obj;
}
-
/**
* @member {Integer} name
*/
@@ -61,3 +64,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
index 9549db64d46..d0236e77b17 100644
--- a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
+++ b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The ModelReturn model module.
* @module model/ModelReturn
@@ -28,6 +31,7 @@
* @class
*/
var exports = function() {
+ var _this = this;
};
@@ -40,7 +44,7 @@
* @return {module:model/ModelReturn} The populated ModelReturn
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('return')) {
@@ -50,7 +54,6 @@
return obj;
}
-
/**
* @member {Integer} return
*/
@@ -61,3 +64,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js
index 08a5a34c29a..93d1d55deb2 100644
--- a/samples/client/petstore/javascript-promise/src/model/Name.js
+++ b/samples/client/petstore/javascript-promise/src/model/Name.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Name model module.
* @module model/Name
@@ -29,8 +32,10 @@
* @param name
*/
var exports = function(name) {
+ var _this = this;
+
+ _this['name'] = name;
- this['name'] = name;
};
@@ -42,7 +47,7 @@
* @return {module:model/Name} The populated Name
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('name')) {
@@ -51,23 +56,30 @@
if (data.hasOwnProperty('snake_case')) {
obj['snake_case'] = ApiClient.convertToType(data['snake_case'], 'Integer');
}
+ if (data.hasOwnProperty('property')) {
+ obj['property'] = ApiClient.convertToType(data['property'], 'String');
+ }
}
return obj;
}
-
/**
* @member {Integer} name
*/
exports.prototype['name'] = undefined;
-
/**
* @member {Integer} snake_case
*/
exports.prototype['snake_case'] = undefined;
+ /**
+ * @member {String} property
+ */
+ exports.prototype['property'] = undefined;
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js
index 664908b77a9..57f77d84ccd 100644
--- a/samples/client/petstore/javascript-promise/src/model/Order.js
+++ b/samples/client/petstore/javascript-promise/src/model/Order.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Order model module.
* @module model/Order
@@ -70,37 +73,32 @@
return obj;
}
-
/**
* @member {Integer} id
*/
exports.prototype['id'] = undefined;
-
/**
* @member {Integer} petId
*/
exports.prototype['petId'] = undefined;
-
/**
* @member {Integer} quantity
*/
exports.prototype['quantity'] = undefined;
-
/**
* @member {Date} shipDate
*/
exports.prototype['shipDate'] = undefined;
-
/**
* Order Status
* @member {module:model/Order.StatusEnum} status
*/
exports.prototype['status'] = undefined;
-
/**
* @member {Boolean} complete
+ * @default false
*/
- exports.prototype['complete'] = undefined;
+ exports.prototype['complete'] = false;
/**
@@ -108,25 +106,25 @@
* @enum {String}
* @readonly
*/
- exports.StatusEnum = {
+ exports.StatusEnum = {
/**
- * value: placed
+ * value: "placed"
* @const
*/
- PLACED: "placed",
-
+ "placed": "placed",
/**
- * value: approved
+ * value: "approved"
* @const
*/
- APPROVED: "approved",
-
+ "approved": "approved",
/**
- * value: delivered
+ * value: "delivered"
* @const
*/
- DELIVERED: "delivered"
- };
+ "delivered": "delivered" };
+
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js
index ae907d35ca2..fe14361dbf2 100644
--- a/samples/client/petstore/javascript-promise/src/model/Pet.js
+++ b/samples/client/petstore/javascript-promise/src/model/Pet.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient, Category, Tag) {
'use strict';
+
+
+
/**
* The Pet model module.
* @module model/Pet
@@ -72,32 +75,26 @@
return obj;
}
-
/**
* @member {Integer} id
*/
exports.prototype['id'] = undefined;
-
/**
* @member {module:model/Category} category
*/
exports.prototype['category'] = undefined;
-
/**
* @member {String} name
*/
exports.prototype['name'] = undefined;
-
/**
* @member {Array.} photoUrls
*/
exports.prototype['photoUrls'] = undefined;
-
/**
* @member {Array.} tags
*/
exports.prototype['tags'] = undefined;
-
/**
* pet status in the store
* @member {module:model/Pet.StatusEnum} status
@@ -110,25 +107,25 @@
* @enum {String}
* @readonly
*/
- exports.StatusEnum = {
+ exports.StatusEnum = {
/**
- * value: available
+ * value: "available"
* @const
*/
- AVAILABLE: "available",
-
+ "available": "available",
/**
- * value: pending
+ * value: "pending"
* @const
*/
- PENDING: "pending",
-
+ "pending": "pending",
/**
- * value: sold
+ * value: "sold"
* @const
*/
- SOLD: "sold"
- };
+ "sold": "sold" };
+
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
index 8694196cdd9..d5a0e992a73 100644
--- a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The SpecialModelName model module.
* @module model/SpecialModelName
@@ -27,6 +30,7 @@
* @class
*/
var exports = function() {
+ var _this = this;
};
@@ -39,7 +43,7 @@
* @return {module:model/SpecialModelName} The populated SpecialModelName
instance.
*/
exports.constructFromObject = function(data, obj) {
- if (data) {
+ if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('$special[property.name]')) {
@@ -49,7 +53,6 @@
return obj;
}
-
/**
* @member {Integer} $special[property.name]
*/
@@ -60,3 +63,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js
index d9ab35fb8b5..443d312b76a 100644
--- a/samples/client/petstore/javascript-promise/src/model/Tag.js
+++ b/samples/client/petstore/javascript-promise/src/model/Tag.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The Tag model module.
* @module model/Tag
@@ -54,12 +57,10 @@
return obj;
}
-
/**
* @member {Integer} id
*/
exports.prototype['id'] = undefined;
-
/**
* @member {String} name
*/
@@ -70,3 +71,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js
index 3bc6aaab630..2360c7c6314 100644
--- a/samples/client/petstore/javascript-promise/src/model/User.js
+++ b/samples/client/petstore/javascript-promise/src/model/User.js
@@ -15,6 +15,9 @@
}(this, function(ApiClient) {
'use strict';
+
+
+
/**
* The User model module.
* @module model/User
@@ -78,42 +81,34 @@
return obj;
}
-
/**
* @member {Integer} id
*/
exports.prototype['id'] = undefined;
-
/**
* @member {String} username
*/
exports.prototype['username'] = undefined;
-
/**
* @member {String} firstName
*/
exports.prototype['firstName'] = undefined;
-
/**
* @member {String} lastName
*/
exports.prototype['lastName'] = undefined;
-
/**
* @member {String} email
*/
exports.prototype['email'] = undefined;
-
/**
* @member {String} password
*/
exports.prototype['password'] = undefined;
-
/**
* @member {String} phone
*/
exports.prototype['phone'] = undefined;
-
/**
* User Status
* @member {Integer} userStatus
@@ -125,3 +120,5 @@
return exports;
}));
+
+
diff --git a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
index 1119546014d..98debb8ea19 100644
--- a/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
+++ b/samples/client/petstore/javascript-promise/test/api/PetApiTest.js
@@ -49,7 +49,7 @@ var createRandomPet = function() {
describe('PetApi', function() {
it('should create and get pet', function(done) {
var pet = createRandomPet();
- api.addPet({body: pet})
+ api.addPet(pet)
.then(function() {
return api.getPetById(pet.id)
})
@@ -63,7 +63,7 @@ describe('PetApi', function() {
.to.be(getProperty(getProperty(pet, "getCategory", "category"), "getName", "name"));
api.deletePet(pet.id);
- done();
+ done();
});
});
});
diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md
index 651e1e6047f..1bf60abb9c3 100644
--- a/samples/client/petstore/javascript/README.md
+++ b/samples/client/petstore/javascript/README.md
@@ -6,7 +6,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0
- Package version: 1.0.0
-- Build date: 2016-05-03T11:05:41.851+08:00
+- Build date: 2016-05-06T18:34:50.267+08:00
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
@@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
## Documentation for Models
- [SwaggerPetstore.Animal](docs/Animal.md)
+ - [SwaggerPetstore.AnimalFarm](docs/AnimalFarm.md)
- [SwaggerPetstore.ApiResponse](docs/ApiResponse.md)
- [SwaggerPetstore.Cat](docs/Cat.md)
- [SwaggerPetstore.Category](docs/Category.md)
@@ -137,12 +138,6 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-### api_key
-
-- **Type**: API key
-- **API key parameter name**: api_key
-- **Location**: HTTP header
-
### petstore_auth
- **Type**: OAuth
@@ -152,3 +147,9 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account
- read:pets: read your pets
+### api_key
+
+- **Type**: API key
+- **API key parameter name**: api_key
+- **Location**: HTTP header
+
diff --git a/samples/client/petstore/javascript/docs/AnimalFarm.md b/samples/client/petstore/javascript/docs/AnimalFarm.md
new file mode 100644
index 00000000000..b72739a44c4
--- /dev/null
+++ b/samples/client/petstore/javascript/docs/AnimalFarm.md
@@ -0,0 +1,7 @@
+# SwaggerPetstore.AnimalFarm
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+
diff --git a/samples/client/petstore/javascript/docs/EnumClass.md b/samples/client/petstore/javascript/docs/EnumClass.md
index 5159ccfb454..04b89362941 100644
--- a/samples/client/petstore/javascript/docs/EnumClass.md
+++ b/samples/client/petstore/javascript/docs/EnumClass.md
@@ -1,7 +1,12 @@
# SwaggerPetstore.EnumClass
-## Properties
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
+## Enum
+
+
+* `_abc` (value: `"_abc"`)
+
+* `-efg` (value: `"-efg"`)
+
+* `(xyz)` (value: `"(xyz)"`)
diff --git a/samples/client/petstore/javascript/docs/EnumTest.md b/samples/client/petstore/javascript/docs/EnumTest.md
index 724eea8a25e..22c4da11b9d 100644
--- a/samples/client/petstore/javascript/docs/EnumTest.md
+++ b/samples/client/petstore/javascript/docs/EnumTest.md
@@ -8,3 +8,36 @@ Name | Type | Description | Notes
**enumNumber** | **Number** | | [optional]
+
+## Enum: EnumStringEnum
+
+
+* `UPPER` (value: `"UPPER"`)
+
+* `lower` (value: `"lower"`)
+
+
+
+
+
+## Enum: EnumIntegerEnum
+
+
+* `1` (value: `1`)
+
+* `-1` (value: `-1`)
+
+
+
+
+
+## Enum: EnumNumberEnum
+
+
+* `1.1` (value: `1.1`)
+
+* `-1.2` (value: `-1.2`)
+
+
+
+
diff --git a/samples/client/petstore/javascript/docs/InlineResponse200.md b/samples/client/petstore/javascript/docs/InlineResponse200.md
deleted file mode 100644
index bbb11067e9a..00000000000
--- a/samples/client/petstore/javascript/docs/InlineResponse200.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# SwaggerPetstore.InlineResponse200
-
-## Properties
-Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
-**tags** | [**[Tag]**](Tag.md) | | [optional]
-**id** | **Integer** | |
-**category** | **Object** | | [optional]
-**status** | **String** | pet status in the store | [optional]
-**name** | **String** | | [optional]
-**photoUrls** | **[String]** | | [optional]
-
-
diff --git a/samples/client/petstore/javascript/docs/Order.md b/samples/client/petstore/javascript/docs/Order.md
index 10503b58206..95ee5946ed2 100644
--- a/samples/client/petstore/javascript/docs/Order.md
+++ b/samples/client/petstore/javascript/docs/Order.md
@@ -11,3 +11,16 @@ Name | Type | Description | Notes
**complete** | **Boolean** | | [optional] [default to false]
+
+## Enum: StatusEnum
+
+
+* `placed` (value: `"placed"`)
+
+* `approved` (value: `"approved"`)
+
+* `delivered` (value: `"delivered"`)
+
+
+
+
diff --git a/samples/client/petstore/javascript/docs/Pet.md b/samples/client/petstore/javascript/docs/Pet.md
index f1b049dcadd..a08333731c0 100644
--- a/samples/client/petstore/javascript/docs/Pet.md
+++ b/samples/client/petstore/javascript/docs/Pet.md
@@ -11,3 +11,16 @@ Name | Type | Description | Notes
**status** | **String** | pet status in the store | [optional]
+
+## Enum: StatusEnum
+
+
+* `available` (value: `"available"`)
+
+* `pending` (value: `"pending"`)
+
+* `sold` (value: `"sold"`)
+
+
+
+
diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js
index d45704dcdac..2598dd8d9ea 100644
--- a/samples/client/petstore/javascript/src/ApiClient.js
+++ b/samples/client/petstore/javascript/src/ApiClient.js
@@ -40,8 +40,8 @@
* @type {Array.}
*/
this.authentications = {
- 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'},
- 'petstore_auth': {type: 'oauth2'}
+ 'petstore_auth': {type: 'oauth2'},
+ 'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key'}
};
/**
* The default HTTP headers to be included for all API calls.
diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js
index 2c3fb27ef65..727b4782f45 100644
--- a/samples/client/petstore/javascript/src/index.js
+++ b/samples/client/petstore/javascript/src/index.js
@@ -1,12 +1,12 @@
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
- define(['ApiClient', 'model/Animal', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
+ define(['ApiClient', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
+ module.exports = factory(require('./ApiClient'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
}
-}(function(ApiClient, Animal, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) {
+}(function(ApiClient, Animal, AnimalFarm, ApiResponse, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, Model200Response, ModelReturn, Name, Order, Pet, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) {
'use strict';
/**
@@ -51,6 +51,11 @@
* @property {module:model/Animal}
*/
Animal: Animal,
+ /**
+ * The AnimalFarm model constructor.
+ * @property {module:model/AnimalFarm}
+ */
+ AnimalFarm: AnimalFarm,
/**
* The ApiResponse model constructor.
* @property {module:model/ApiResponse}
diff --git a/samples/client/petstore/javascript/src/model/AnimalFarm.js b/samples/client/petstore/javascript/src/model/AnimalFarm.js
new file mode 100644
index 00000000000..d5f6aa2a424
--- /dev/null
+++ b/samples/client/petstore/javascript/src/model/AnimalFarm.js
@@ -0,0 +1,64 @@
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['ApiClient', 'model/Animal'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ module.exports = factory(require('../ApiClient'), require('./Animal'));
+ } else {
+ // Browser globals (root is window)
+ if (!root.SwaggerPetstore) {
+ root.SwaggerPetstore = {};
+ }
+ root.SwaggerPetstore.AnimalFarm = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Animal);
+ }
+}(this, function(ApiClient, Animal) {
+ 'use strict';
+
+
+
+
+ /**
+ * The AnimalFarm model module.
+ * @module model/AnimalFarm
+ * @version 1.0.0
+ */
+
+ /**
+ * Constructs a new AnimalFarm
.
+ * @alias module:model/AnimalFarm
+ * @class
+ * @extends Array
+ */
+ var exports = function() {
+ var _this = this;
+ _this = new Array();
+ Object.setPrototypeOf(_this, exports);
+
+ return _this;
+ };
+
+ /**
+ * Constructs a AnimalFarm
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {module:model/AnimalFarm} obj Optional instance to populate.
+ * @return {module:model/AnimalFarm} The populated AnimalFarm
instance.
+ */
+ exports.constructFromObject = function(data, obj) {
+ if (data) {
+ obj = obj || new exports();
+ ApiClient.constructFromObject(data, obj, Animal);
+
+ }
+ return obj;
+ }
+
+
+
+
+
+ return exports;
+}));
+
+
diff --git a/samples/client/petstore/javascript/src/model/EnumClass.js b/samples/client/petstore/javascript/src/model/EnumClass.js
index 2ff3398113a..e9bf5219ee5 100644
--- a/samples/client/petstore/javascript/src/model/EnumClass.js
+++ b/samples/client/petstore/javascript/src/model/EnumClass.js
@@ -21,19 +21,19 @@
* @enum {}
* @readonly
*/
- exports.EnumClass = {
+ var exports = {
/**
- * value: _abc
+ * value: "_abc"
* @const
*/
"_abc": "_abc",
/**
- * value: -efg
+ * value: "-efg"
* @const
*/
"-efg": "-efg",
/**
- * value: (xyz)
+ * value: "(xyz)"
* @const
*/
"(xyz)": "(xyz)" };
diff --git a/samples/client/petstore/javascript/src/model/InlineResponse200.js b/samples/client/petstore/javascript/src/model/InlineResponse200.js
deleted file mode 100644
index f2abaf1bd1b..00000000000
--- a/samples/client/petstore/javascript/src/model/InlineResponse200.js
+++ /dev/null
@@ -1,132 +0,0 @@
-(function(root, factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['ApiClient', 'model/Tag'], factory);
- } else if (typeof module === 'object' && module.exports) {
- // CommonJS-like environments that support module.exports, like Node.
- module.exports = factory(require('../ApiClient'), require('./Tag'));
- } else {
- // Browser globals (root is window)
- if (!root.SwaggerPetstore) {
- root.SwaggerPetstore = {};
- }
- root.SwaggerPetstore.InlineResponse200 = factory(root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Tag);
- }
-}(this, function(ApiClient, Tag) {
- 'use strict';
-
- /**
- * The InlineResponse200 model module.
- * @module model/InlineResponse200
- * @version 1.0.0
- */
-
- /**
- * Constructs a new InlineResponse200
.
- * @alias module:model/InlineResponse200
- * @class
- * @param id
- */
- var exports = function(id) {
-
-
- this['id'] = id;
-
-
-
-
- };
-
- /**
- * Constructs a InlineResponse200
from a plain JavaScript object, optionally creating a new instance.
- * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
- * @param {Object} data The plain JavaScript object bearing properties of interest.
- * @param {module:model/InlineResponse200} obj Optional instance to populate.
- * @return {module:model/InlineResponse200} The populated InlineResponse200
instance.
- */
- exports.constructFromObject = function(data, obj) {
- if (data) {
- obj = obj || new exports();
-
- if (data.hasOwnProperty('tags')) {
- obj['tags'] = ApiClient.convertToType(data['tags'], [Tag]);
- }
- if (data.hasOwnProperty('id')) {
- obj['id'] = ApiClient.convertToType(data['id'], 'Integer');
- }
- if (data.hasOwnProperty('category')) {
- obj['category'] = ApiClient.convertToType(data['category'], Object);
- }
- if (data.hasOwnProperty('status')) {
- obj['status'] = ApiClient.convertToType(data['status'], 'String');
- }
- if (data.hasOwnProperty('name')) {
- obj['name'] = ApiClient.convertToType(data['name'], 'String');
- }
- if (data.hasOwnProperty('photoUrls')) {
- obj['photoUrls'] = ApiClient.convertToType(data['photoUrls'], ['String']);
- }
- }
- return obj;
- }
-
-
- /**
- * @member {Array.} tags
- */
- exports.prototype['tags'] = undefined;
-
- /**
- * @member {Integer} id
- */
- exports.prototype['id'] = undefined;
-
- /**
- * @member {Object} category
- */
- exports.prototype['category'] = undefined;
-
- /**
- * pet status in the store
- * @member {module:model/InlineResponse200.StatusEnum} status
- */
- exports.prototype['status'] = undefined;
-
- /**
- * @member {String} name
- */
- exports.prototype['name'] = undefined;
-
- /**
- * @member {Array.} photoUrls
- */
- exports.prototype['photoUrls'] = undefined;
-
-
- /**
- * Allowed values for the status
property.
- * @enum {String}
- * @readonly
- */
- exports.StatusEnum = {
- /**
- * value: available
- * @const
- */
- AVAILABLE: "available",
-
- /**
- * value: pending
- * @const
- */
- PENDING: "pending",
-
- /**
- * value: sold
- * @const
- */
- SOLD: "sold"
- };
-
- return exports;
-}));
diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md
index bd0f24851a7..f4b3f2f2f76 100644
--- a/samples/client/petstore/objc/README.md
+++ b/samples/client/petstore/objc/README.md
@@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi
- API version: 1.0.0
- Package version:
-- Build date: 2016-04-25T18:52:19.055+02:00
+- Build date: 2016-05-08T12:06:01.121+02:00
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements
@@ -19,7 +19,7 @@ The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.c
Add the following to the Podfile:
```ruby
-pod 'SwaggerClient', :git => 'https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git'
+pod 'SwaggerClient', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
```
To specify a particular branch, append `, :branch => 'branch-name-here'`
diff --git a/samples/client/petstore/objc/SwaggerClient/SWG200Response.h b/samples/client/petstore/objc/SwaggerClient/SWG200Response.h
deleted file mode 100644
index c576bc204ad..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWG200Response.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#import
-#import "SWGObject.h"
-
-/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-
-
-
-@protocol SWG200Response
-@end
-
-@interface SWG200Response : SWGObject
-
-
-@property(nonatomic) NSNumber* name;
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWG200Response.m b/samples/client/petstore/objc/SwaggerClient/SWG200Response.m
deleted file mode 100644
index 9cafc782f1a..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWG200Response.m
+++ /dev/null
@@ -1,51 +0,0 @@
-#import "SWG200Response.h"
-
-@implementation SWG200Response
-
-- (instancetype)init {
- self = [super init];
-
- if (self) {
- // initalise property's default value, if any
-
- }
-
- return self;
-}
-
-
-/**
- * Maps json key to property name.
- * This method is used by `JSONModel`.
- */
-+ (JSONKeyMapper *)keyMapper
-{
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name" }];
-}
-
-/**
- * Indicates whether the property with the given name is optional.
- * If `propertyName` is optional, then return `YES`, otherwise return `NO`.
- * This method is used by `JSONModel`.
- */
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
- NSArray *optionalProperties = @[@"name"];
-
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
-}
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h
index 5d40ef2f5f0..82472ab20bf 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h
+++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h
@@ -1,11 +1,12 @@
#import
#import
-#import
+#import
#import "SWGJSONResponseSerializer.h"
#import "SWGJSONRequestSerializer.h"
#import "SWGQueryParamCollection.h"
#import "SWGConfiguration.h"
-
+#import "SWGResponseDeserializer.h"
+#import "SWGSanitizer.h"
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
@@ -29,22 +30,14 @@
*/
extern NSString *const SWGResponseObjectErrorKey;
-/**
- * A key for deserialization ErrorDomain
- */
-extern NSString *const SWGDeserializationErrorDomainKey;
-
-/**
- * Code for deserialization type mismatch error
- */
-extern NSInteger const SWGTypeMismatchErrorCode;
-
/**
* Log debug message macro
*/
-#define SWGDebugLog(format, ...) [SWGApiClient debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__];
+#ifndef SWGDebugLog
+ #define SWGDebugLog(format, ...) [SWGApiClient debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__];
+#endif
-@interface SWGApiClient : AFHTTPRequestOperationManager
+@interface SWGApiClient : AFHTTPSessionManager
@property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
@@ -53,6 +46,9 @@ extern NSInteger const SWGTypeMismatchErrorCode;
/// In order to ensure the HTTPResponseHeaders are correct, it is recommended to initialize one SWGApiClient instance per thread.
@property(nonatomic, readonly) NSDictionary* HTTPResponseHeaders;
+@property(nonatomic, strong) id responseDeserializer;
+
+@property(nonatomic, strong) id sanitizer;
/**
* Clears Cache
*/
@@ -84,7 +80,7 @@ extern NSInteger const SWGTypeMismatchErrorCode;
*
* @return The client offline state
*/
-+(bool) getOfflineState;
++(BOOL) getOfflineState;
/**
* Sets the client reachability, this may be overridden by the reachability manager if reachability changes
@@ -180,24 +176,17 @@ extern NSInteger const SWGTypeMismatchErrorCode;
queryParams:(NSDictionary **)querys
WithAuthSettings:(NSArray *)authSettings;
-/**
- * Deserializes the given data to Objective-C object.
- *
- * @param data The data will be deserialized.
- * @param class The type of objective-c object.
- * @param error The error
- */
-- (id) deserialize:(id) data class:(NSString *) class error:(NSError**)error;
-
/**
* Logs request and response
*
- * @param operation AFHTTPRequestOperation for the HTTP request.
+ * @param response NSURLResponse for the HTTP request.
+ * @param responseObject response object of the HTTP request.
* @param request The HTTP request.
* @param error The error of the HTTP request.
*/
-- (void)logResponse:(AFHTTPRequestOperation *)operation
- forRequest:(NSURLRequest *)request
+- (void)logResponse:(NSURLResponse *)response
+ responseObject:(id)responseObject
+ request:(NSURLRequest *)request
error:(NSError *)error;
/**
@@ -230,13 +219,6 @@ extern NSInteger const SWGTypeMismatchErrorCode;
responseType:(NSString *) responseType
completionBlock:(void (^)(id, NSError *))completionBlock;
-/**
- * Sanitize object for request
- *
- * @param object The query/path/header/form/body param to be sanitized.
- */
-- (id) sanitizeForSerialization:(id) object;
-
/**
* Custom security policy
*
@@ -244,11 +226,6 @@ extern NSInteger const SWGTypeMismatchErrorCode;
*/
- (AFSecurityPolicy *) customSecurityPolicy;
-/**
- * Convert parameter to NSString
- */
-- (NSString *) parameterToString: (id) param;
-
/**
* Log debug message
*/
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m
index ecdf4aaafb2..1246dff7fca 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m
@@ -2,10 +2,6 @@
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
-NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey";
-
-NSInteger const SWGTypeMismatchErrorCode = 143553;
-
static long requestId = 0;
static bool offlineState = false;
static NSMutableSet * queuedRequests = nil;
@@ -14,6 +10,30 @@ static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilitySta
static void (^reachabilityChangeBlock)(int);
+static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) {
+ if(![response isKindOfClass:[NSHTTPURLResponse class]]) {
+ return nil;
+ }
+ return ((NSHTTPURLResponse*)response).allHeaderFields;
+}
+
+static NSString * SWG__fileNameForResponse(NSURLResponse *response) {
+ NSDictionary * headers = SWG__headerFieldsForResponse(response);
+ if(!headers[@"Content-Disposition"]) {
+ return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
+ }
+ NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?";
+ NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern
+ options:NSRegularExpressionCaseInsensitive
+ error:nil];
+ NSString *contentDispositionHeader = headers[@"Content-Disposition"];
+ NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader
+ options:0
+ range:NSMakeRange(0, [contentDispositionHeader length])];
+ return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]];
+}
+
+
@interface SWGApiClient ()
@property (readwrite, nonatomic) NSDictionary *HTTPResponseHeaders;
@@ -33,6 +53,8 @@ static void (^reachabilityChangeBlock)(int);
self.requestSerializer = [AFJSONRequestSerializer serializer];
self.responseSerializer = [AFJSONResponseSerializer serializer];
self.securityPolicy = [self customSecurityPolicy];
+ self.responseDeserializer = [[SWGResponseDeserializer alloc] init];
+ self.sanitizer = [[SWGSanitizer alloc] init];
// configure reachability
[self configureCacheReachibility];
}
@@ -99,14 +121,12 @@ static void (^reachabilityChangeBlock)(int);
va_end(args);
}
-- (void)logResponse:(AFHTTPRequestOperation *)operation
- forRequest:(NSURLRequest *)request
- error:(NSError*)error {
+- (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error {
NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\
"[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n",
[[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding],
- operation.responseString];
+ responseObject];
SWGDebugLog(message);
}
@@ -222,20 +242,14 @@ static void (^reachabilityChangeBlock)(int);
-(Boolean) executeRequestWithId:(NSNumber*) requestId {
NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) {
- if ([obj intValue] == [requestId intValue]) {
- return YES;
- }
- else {
- return NO;
- }
+ return [obj intValue] == [requestId intValue];
}];
if (matchingItems.count == 1) {
SWGDebugLog(@"removed request id %@", requestId);
[queuedRequests removeObject:requestId];
return YES;
- }
- else {
+ } else {
return NO;
}
}
@@ -246,7 +260,7 @@ static void (^reachabilityChangeBlock)(int);
return reachabilityStatus;
}
-+(bool) getOfflineState {
++(BOOL) getOfflineState {
return offlineState;
}
@@ -257,29 +271,8 @@ static void (^reachabilityChangeBlock)(int);
- (void) configureCacheReachibility {
[self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
reachabilityStatus = status;
- switch (status) {
- case AFNetworkReachabilityStatusUnknown:
- SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusUnknown");
- [SWGApiClient setOfflineState:true];
- break;
-
- case AFNetworkReachabilityStatusNotReachable:
- SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable");
- [SWGApiClient setOfflineState:true];
- break;
-
- case AFNetworkReachabilityStatusReachableViaWWAN:
- SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN");
- [SWGApiClient setOfflineState:false];
- break;
-
- case AFNetworkReachabilityStatusReachableViaWiFi:
- SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi");
- [SWGApiClient setOfflineState:false];
- break;
- default:
- break;
- }
+ SWGDebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status));
+ [SWGApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable];
// call the reachability block, if configured
if (reachabilityChangeBlock != nil) {
@@ -290,245 +283,65 @@ static void (^reachabilityChangeBlock)(int);
[self.reachabilityManager startMonitoring];
}
-#pragma mark - Deserialize methods
-
-- (id) deserialize:(id) data class:(NSString *) class error:(NSError **) error {
- // return nil if data is nil or class is nil
- if (!data || !class) {
- return nil;
- }
-
- // remove "*" from class, if ends with "*"
- if ([class hasSuffix:@"*"]) {
- class = [class substringToIndex:[class length] - 1];
- }
-
- // pure object
- if ([class isEqualToString:@"NSObject"]) {
- return data;
- }
-
- NSRegularExpression *regexp = nil;
- NSTextCheckingResult *match = nil;
- NSMutableArray *resultArray = nil;
- NSMutableDictionary *resultDict = nil;
- NSString *innerType = nil;
-
- // list of models
- NSString *arrayOfModelsPat = @"NSArray<(.+)>";
- regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat
- options:NSRegularExpressionCaseInsensitive
- error:nil];
-
- match = [regexp firstMatchInString:class
- options:0
- range:NSMakeRange(0, [class length])];
-
- if (match) {
- if(![data isKindOfClass: [NSArray class]]) {
- if(error) {
- NSDictionary * userInfo = @{NSLocalizedDescriptionKey : NSLocalizedString(@"Received response is not an array", nil)};
- *error = [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo];
- }
- return nil;
- }
- NSArray *dataArray = data;
- innerType = [class substringWithRange:[match rangeAtIndex:1]];
-
- resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]];
- [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- id arrObj = [self deserialize:obj class:innerType error:error];
- if(arrObj) {
- [resultArray addObject:arrObj];
- } else {
- * stop = YES;
- }
- }];
-
- return resultArray;
- }
-
- // list of primitives
- NSString *arrayOfPrimitivesPat = @"NSArray\\* /\\* (.+) \\*/";
- regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfPrimitivesPat
- options:NSRegularExpressionCaseInsensitive
- error:nil];
- match = [regexp firstMatchInString:class
- options:0
- range:NSMakeRange(0, [class length])];
-
- if (match) {
- NSArray *dataArray = data;
- innerType = [class substringWithRange:[match rangeAtIndex:1]];
-
- resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]];
- [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- id arrObj = [self deserialize:obj class:innerType error:error];
- if(arrObj) {
- [resultArray addObject:arrObj];
- } else {
- * stop = YES;
- }
- }];
-
- return resultArray;
- }
-
- // map
- NSString *dictPat = @"NSDictionary\\* /\\* (.+?), (.+) \\*/";
- regexp = [NSRegularExpression regularExpressionWithPattern:dictPat
- options:NSRegularExpressionCaseInsensitive
- error:nil];
- match = [regexp firstMatchInString:class
- options:0
- range:NSMakeRange(0, [class length])];
-
- if (match) {
- NSDictionary *dataDict = data;
- NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]];
-
- resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]];
- [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
- id dicObj = [self deserialize:obj class:valueType error:error];
- if(dicObj) {
- [resultDict setValue:dicObj forKey:key];
- } else {
- * stop = YES;
- }
- }];
-
- return resultDict;
- }
-
- // primitives
- NSArray *primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
-
- if ([primitiveTypes containsObject:class]) {
- if ([class isEqualToString:@"NSString"]) {
- return [NSString stringWithString:data];
- }
- else if ([class isEqualToString:@"NSDate"]) {
- return [NSDate dateWithISO8601String:data];
- }
- else if ([class isEqualToString:@"NSNumber"]) {
- // NSNumber from NSNumber
- if ([data isKindOfClass:[NSNumber class]]) {
- return data;
- }
- else if ([data isKindOfClass:[NSString class]]) {
- // NSNumber (NSCFBoolean) from NSString
- if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) {
- return [NSNumber numberWithBool:[data boolValue]];
- // NSNumber from NSString
- } else {
- NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
- formatter.numberStyle = NSNumberFormatterDecimalStyle;
- return [formatter numberFromString:data];
- }
- }
- }
- }
-
- // model
- Class ModelClass = NSClassFromString(class);
- if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) {
- return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error];
- }
-
- return nil;
-}
-
#pragma mark - Operation Methods
- (void) operationWithCompletionBlock: (NSURLRequest *)request
requestId: (NSNumber *) requestId
completionBlock: (void (^)(id, NSError *))completionBlock {
- AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
- success:^(AFHTTPRequestOperation *operation, id response) {
- if ([self executeRequestWithId:requestId]) {
- [self logResponse:operation forRequest:request error:nil];
- NSDictionary *responseHeaders = [[operation response] allHeaderFields];
- self.HTTPResponseHeaders = responseHeaders;
- completionBlock(response, nil);
- }
- } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
- if ([self executeRequestWithId:requestId]) {
- NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
- if (operation.responseObject) {
- // Add in the (parsed) response body.
- userInfo[SWGResponseObjectErrorKey] = operation.responseObject;
- }
- NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
- [self logResponse:nil forRequest:request error:augmentedError];
-
- NSDictionary *responseHeaders = [[operation response] allHeaderFields];
- self.HTTPResponseHeaders = responseHeaders;
-
- completionBlock(nil, augmentedError);
- }
- }];
-
- [self.operationQueue addOperation:op];
+ __weak __typeof(self)weakSelf = self;
+ NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
+ if (![strongSelf executeRequestWithId:requestId]) {
+ return;
+ }
+ [strongSelf logResponse:response responseObject:responseObject request:request error:error];
+ strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
+ if(!error) {
+ completionBlock(responseObject, nil);
+ return;
+ }
+ NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
+ if (responseObject) {
+ // Add in the (parsed) response body.
+ userInfo[SWGResponseObjectErrorKey] = responseObject;
+ }
+ NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
+ completionBlock(nil, augmentedError);
+ }];
+ [op resume];
}
- (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request
requestId: (NSNumber *) requestId
completionBlock: (void (^)(id, NSError *))completionBlock {
- AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
- success:^(AFHTTPRequestOperation *operation, id responseObject) {
- SWGConfiguration *config = [SWGConfiguration sharedConfig];
- NSString *directory = nil;
- if (config.tempFolderPath) {
- directory = config.tempFolderPath;
- }
- else {
- directory = NSTemporaryDirectory();
- }
+ __weak __typeof(self)weakSelf = self;
+ NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+ __strong __typeof(weakSelf)strongSelf = weakSelf;
+ if (![strongSelf executeRequestWithId:requestId]) {
+ return;
+ }
+ strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response);
+ [strongSelf logResponse:response responseObject:responseObject request:request error:error];
+ if(error) {
+ NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
+ if (responseObject) {
+ userInfo[SWGResponseObjectErrorKey] = responseObject;
+ }
+ NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
+ completionBlock(nil, augmentedError);
+ }
+ SWGConfiguration *config = [SWGConfiguration sharedConfig];
+ NSString *directory = config.tempFolderPath ?: NSTemporaryDirectory();
+ NSString * filename = SWG__fileNameForResponse(response);
- NSDictionary *headers = operation.response.allHeaderFields;
- NSString *filename = nil;
- if ([headers objectForKey:@"Content-Disposition"]) {
+ NSString *filepath = [directory stringByAppendingPathComponent:filename];
+ NSURL *file = [NSURL fileURLWithPath:filepath];
- NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?";
- NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern
- options:NSRegularExpressionCaseInsensitive
- error:nil];
- NSString *contentDispositionHeader = [headers objectForKey:@"Content-Disposition"];
- NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader
- options:0
- range:NSMakeRange(0, [contentDispositionHeader length])];
- filename = [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]];
- }
- else {
- filename = [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
- }
+ [responseObject writeToURL:file atomically:YES];
- NSString *filepath = [directory stringByAppendingPathComponent:filename];
- NSURL *file = [NSURL fileURLWithPath:filepath];
-
- [operation.responseData writeToURL:file atomically:YES];
- self.HTTPResponseHeaders = headers;
- completionBlock(file, nil);
- } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
-
- if ([self executeRequestWithId:requestId]) {
- NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
- if (operation.responseObject) {
- userInfo[SWGResponseObjectErrorKey] = operation.responseObject;
- }
-
- NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
-
-
- [self logResponse:nil forRequest:request error:augmentedError];
-
- NSDictionary *responseHeaders = [[operation response] allHeaderFields];
- self.HTTPResponseHeaders = responseHeaders;
- completionBlock(nil, augmentedError);
- }
- }];
-
- [self.operationQueue addOperation:op];
+ completionBlock(file, nil);
+ }];
+ [op resume];
}
#pragma mark - Perform Request Methods
@@ -569,11 +382,11 @@ static void (^reachabilityChangeBlock)(int);
}
// sanitize parameters
- pathParams = [self sanitizeForSerialization:pathParams];
- queryParams = [self sanitizeForSerialization:queryParams];
- headerParams = [self sanitizeForSerialization:headerParams];
- formParams = [self sanitizeForSerialization:formParams];
- body = [self sanitizeForSerialization:body];
+ pathParams = [self.sanitizer sanitizeForSerialization:pathParams];
+ queryParams = [self.sanitizer sanitizeForSerialization:queryParams];
+ headerParams = [self.sanitizer sanitizeForSerialization:headerParams];
+ formParams = [self.sanitizer sanitizeForSerialization:formParams];
+ body = [self.sanitizer sanitizeForSerialization:body];
// auth setting
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
@@ -593,12 +406,13 @@ static void (^reachabilityChangeBlock)(int);
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
if (files.count > 0) {
+ __weak __typeof(self)weakSelf = self;
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
URLString:urlString
parameters:nil
constructingBodyWithBlock:^(id formData) {
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
- NSString *objString = [self parameterToString:obj];
+ NSString *objString = [weakSelf.sanitizer parameterToString:obj];
NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding];
[formData appendPartWithFormData:data name:key];
}];
@@ -653,7 +467,7 @@ static void (^reachabilityChangeBlock)(int);
[request setHTTPShouldHandleCookies:NO];
NSNumber* requestId = [SWGApiClient queueRequest];
- if ([responseType isEqualToString:@"NSURL*"]) {
+ if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) {
[self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
completionBlock(data, error);
}];
@@ -661,7 +475,7 @@ static void (^reachabilityChangeBlock)(int);
else {
[self operationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
NSError * serializationError;
- id response = [self deserialize:data class:responseType error:&serializationError];
+ id response = [self.responseDeserializer deserialize:data class:responseType error:&serializationError];
if(!response && !error){
error = serializationError;
}
@@ -760,48 +574,6 @@ static void (^reachabilityChangeBlock)(int);
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
}
-- (id) sanitizeForSerialization:(id) object {
- if (object == nil) {
- return nil;
- }
- else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) {
- return object;
- }
- else if ([object isKindOfClass:[NSDate class]]) {
- return [object ISO8601String];
- }
- else if ([object isKindOfClass:[NSArray class]]) {
- NSArray *objectArray = object;
- NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]];
- [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if (obj) {
- [sanitizedObjs addObject:[self sanitizeForSerialization:obj]];
- }
- }];
- return sanitizedObjs;
- }
- else if ([object isKindOfClass:[NSDictionary class]]) {
- NSDictionary *objectDict = object;
- NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]];
- [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
- if (obj) {
- [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key];
- }
- }];
- return sanitizedObjs;
- }
- else if ([object isKindOfClass:[SWGObject class]]) {
- return [object toDictionary];
- }
- else {
- NSException *e = [NSException
- exceptionWithName:@"InvalidObjectArgumentException"
- reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object]
- userInfo:nil];
- @throw e;
- }
-}
-
- (AFSecurityPolicy *) customSecurityPolicy {
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
@@ -823,30 +595,4 @@ static void (^reachabilityChangeBlock)(int);
return securityPolicy;
}
-- (NSString *) parameterToString:(id)param {
- if ([param isKindOfClass:[NSString class]]) {
- return param;
- }
- else if ([param isKindOfClass:[NSNumber class]]) {
- return [param stringValue];
- }
- else if ([param isKindOfClass:[NSDate class]]) {
- return [param ISO8601String];
- }
- else if ([param isKindOfClass:[NSArray class]]) {
- NSMutableArray *mutableParam;
- [param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- [mutableParam addObject:[self parameterToString:obj]];
- }];
- return [mutableParam componentsJoinedByString:@","];
- }
- else {
- NSException *e = [NSException
- exceptionWithName:@"InvalidObjectArgumentException"
- reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param]
- userInfo:nil];
- @throw e;
- }
-}
-
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m
index c323eda5a0a..29e3bc16226 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m
@@ -4,12 +4,10 @@
- (instancetype)init {
self = [super init];
-
if (self) {
// initalise property's default value, if any
}
-
return self;
}
@@ -18,8 +16,7 @@
* Maps json key to property name.
* This method is used by `JSONModel`.
*/
-+ (JSONKeyMapper *)keyMapper
-{
++ (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }];
}
@@ -28,24 +25,11 @@
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
* This method is used by `JSONModel`.
*/
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
++ (BOOL)propertyIsOptional:(NSString *)propertyName {
+
NSArray *optionalProperties = @[@"_id", @"name"];
+ return [optionalProperties containsObject:propertyName];
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
}
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m
index c9d80f5c488..dd1596bf8ce 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m
@@ -72,7 +72,7 @@
return @"";
}
else {
- return [NSString stringWithFormat:@"BEARER %@", self.accessToken];
+ return [NSString stringWithFormat:@"Bearer %@", self.accessToken];
}
}
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h
deleted file mode 100644
index 577434faae6..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#import
-#import "SWGObject.h"
-
-/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-
-#import "SWGTag.h"
-
-
-@protocol SWGInlineResponse200
-@end
-
-@interface SWGInlineResponse200 : SWGObject
-
-
-@property(nonatomic) NSArray* /* NSString */ photoUrls;
-
-@property(nonatomic) NSString* name;
-
-@property(nonatomic) NSNumber* _id;
-
-@property(nonatomic) NSObject* category;
-
-@property(nonatomic) NSArray* tags;
-/* pet status in the store [optional]
- */
-@property(nonatomic) NSString* status;
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m b/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m
deleted file mode 100644
index 5fbe9ec6ec2..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGInlineResponse200.m
+++ /dev/null
@@ -1,51 +0,0 @@
-#import "SWGInlineResponse200.h"
-
-@implementation SWGInlineResponse200
-
-- (instancetype)init {
- self = [super init];
-
- if (self) {
- // initalise property's default value, if any
-
- }
-
- return self;
-}
-
-
-/**
- * Maps json key to property name.
- * This method is used by `JSONModel`.
- */
-+ (JSONKeyMapper *)keyMapper
-{
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"photoUrls": @"photoUrls", @"name": @"name", @"id": @"_id", @"category": @"category", @"tags": @"tags", @"status": @"status" }];
-}
-
-/**
- * Indicates whether the property with the given name is optional.
- * If `propertyName` is optional, then return `YES`, otherwise return `NO`.
- * This method is used by `JSONModel`.
- */
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
- NSArray *optionalProperties = @[@"photoUrls", @"name", @"category", @"tags", @"status"];
-
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
-}
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.h b/samples/client/petstore/objc/SwaggerClient/SWGName.h
deleted file mode 100644
index fd34af7b66a..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGName.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#import
-#import "SWGObject.h"
-
-/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-
-
-
-@protocol SWGName
-@end
-
-@interface SWGName : SWGObject
-
-
-@property(nonatomic) NSNumber* name;
-
-@property(nonatomic) NSNumber* snakeCase;
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGName.m b/samples/client/petstore/objc/SwaggerClient/SWGName.m
deleted file mode 100644
index 16aec784549..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGName.m
+++ /dev/null
@@ -1,51 +0,0 @@
-#import "SWGName.h"
-
-@implementation SWGName
-
-- (instancetype)init {
- self = [super init];
-
- if (self) {
- // initalise property's default value, if any
-
- }
-
- return self;
-}
-
-
-/**
- * Maps json key to property name.
- * This method is used by `JSONModel`.
- */
-+ (JSONKeyMapper *)keyMapper
-{
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name", @"snake_case": @"snakeCase" }];
-}
-
-/**
- * Indicates whether the property with the given name is optional.
- * If `propertyName` is optional, then return `YES`, otherwise return `NO`.
- * This method is used by `JSONModel`.
- */
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
- NSArray *optionalProperties = @[@"snakeCase"];
-
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
-}
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGObject.m b/samples/client/petstore/objc/SwaggerClient/SWGObject.m
index 1f897ab1d56..8085c404f7e 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGObject.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGObject.m
@@ -1,4 +1,13 @@
#import "SWGObject.h"
@implementation SWGObject
+
+/**
+ * Gets the string presentation of the object.
+ * This method will be called when logging model object using `NSLog`.
+ */
+- (NSString *)description {
+ return [[self toDictionary] description];
+}
+
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m
index e41bc7a188d..d10ed802b8d 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m
@@ -4,12 +4,10 @@
- (instancetype)init {
self = [super init];
-
if (self) {
// initalise property's default value, if any
}
-
return self;
}
@@ -18,8 +16,7 @@
* Maps json key to property name.
* This method is used by `JSONModel`.
*/
-+ (JSONKeyMapper *)keyMapper
-{
++ (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }];
}
@@ -28,24 +25,11 @@
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
* This method is used by `JSONModel`.
*/
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
++ (BOOL)propertyIsOptional:(NSString *)propertyName {
+
NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"];
+ return [optionalProperties containsObject:propertyName];
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
}
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h
index 84f10969e5b..2f83af6c4e1 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h
+++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h
@@ -23,7 +23,7 @@
@property(nonatomic) NSString* name;
-@property(nonatomic) NSArray* /* NSString */ photoUrls;
+@property(nonatomic) NSArray* photoUrls;
@property(nonatomic) NSArray* tags;
/* pet status in the store [optional]
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m
index 86389c2590b..98e75189ed3 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m
@@ -4,12 +4,10 @@
- (instancetype)init {
self = [super init];
-
if (self) {
// initalise property's default value, if any
}
-
return self;
}
@@ -18,8 +16,7 @@
* Maps json key to property name.
* This method is used by `JSONModel`.
*/
-+ (JSONKeyMapper *)keyMapper
-{
++ (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }];
}
@@ -28,24 +25,11 @@
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
* This method is used by `JSONModel`.
*/
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
++ (BOOL)propertyIsOptional:(NSString *)propertyName {
+
NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"];
+ return [optionalProperties containsObject:propertyName];
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
}
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h
index ef66979613f..908771588e0 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h
+++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h
@@ -56,7 +56,7 @@
///
///
/// @return NSArray*
--(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status
+-(NSNumber*) findPetsByStatusWithStatus: (NSArray*) status
completionHandler: (void (^)(NSArray* output, NSError* error)) handler;
@@ -69,7 +69,7 @@
///
///
/// @return NSArray*
--(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags
+-(NSNumber*) findPetsByTagsWithTags: (NSArray*) tags
completionHandler: (void (^)(NSArray* output, NSError* error)) handler;
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m
index 87201064542..b3ebc31bf68 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m
@@ -217,7 +217,7 @@ static SWGPetApi* singletonAPI = nil;
///
/// @returns NSArray*
///
--(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status
+-(NSNumber*) findPetsByStatusWithStatus: (NSArray*) status
completionHandler: (void (^)(NSArray* output, NSError* error)) handler {
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/findByStatus"];
@@ -284,7 +284,7 @@ static SWGPetApi* singletonAPI = nil;
///
/// @returns NSArray*
///
--(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags
+-(NSNumber*) findPetsByTagsWithTags: (NSArray*) tags
completionHandler: (void (^)(NSArray* output, NSError* error)) handler {
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/pet/findByTags"];
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h
new file mode 100644
index 00000000000..b20ead44f83
--- /dev/null
+++ b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.h
@@ -0,0 +1,50 @@
+#import
+
+/**
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+
+/**
+ * A key for deserialization ErrorDomain
+ */
+extern NSString *const SWGDeserializationErrorDomainKey;
+
+/**
+ * Code for deserialization type mismatch error
+ */
+extern NSInteger const SWGTypeMismatchErrorCode;
+
+/**
+ * Code for deserialization empty value error
+ */
+extern NSInteger const SWGEmptyValueOccurredErrorCode;
+
+/**
+ * Error code for unknown response
+ */
+extern NSInteger const SWGUnknownResponseObjectErrorCode;
+
+@protocol SWGResponseDeserializer
+
+/**
+ * Deserializes the given data to Objective-C object.
+ *
+ * @param data The data will be deserialized.
+ * @param class The type of objective-c object.
+ * @param error The error
+ */
+- (id) deserialize:(id) data class:(NSString *) className error:(NSError**)error;
+
+@end
+
+@interface SWGResponseDeserializer : NSObject
+
+/**
+ * If an null value occurs in dictionary or array if set to YES whole response will be invalid else will be ignored
+ * @default NO
+ */
+@property (nonatomic, assign) BOOL treatNullAsError;
+
+@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m
new file mode 100644
index 00000000000..a0efd1d5927
--- /dev/null
+++ b/samples/client/petstore/objc/SwaggerClient/SWGResponseDeserializer.m
@@ -0,0 +1,231 @@
+#import "SWGResponseDeserializer.h"
+#import
+#import
+
+NSString *const SWGDeserializationErrorDomainKey = @"SWGDeserializationErrorDomainKey";
+
+NSInteger const SWGTypeMismatchErrorCode = 143553;
+
+NSInteger const SWGEmptyValueOccurredErrorCode = 143509;
+
+NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
+
+
+@interface SWGResponseDeserializer ()
+
+@property (nonatomic, strong) NSNumberFormatter* numberFormatter;
+@property (nonatomic, strong) NSArray *primitiveTypes;
+@property (nonatomic, strong) NSArray *basicReturnTypes;
+
+@property (nonatomic, strong) NSRegularExpression* arrayOfModelsPatExpression;
+@property (nonatomic, strong) NSRegularExpression* arrayOfPrimitivesPatExpression;
+@property (nonatomic, strong) NSRegularExpression* dictPatExpression;
+@property (nonatomic, strong) NSRegularExpression* dictModelsPatExpression;
+
+@end
+
+@implementation SWGResponseDeserializer
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
+ formatter.numberStyle = NSNumberFormatterDecimalStyle;
+ _numberFormatter = formatter;
+ _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
+ _basicReturnTypes = @[@"NSObject", @"id", @"NSData"];
+ _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>"
+ options:NSRegularExpressionCaseInsensitive
+ error:nil];
+ _arrayOfPrimitivesPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray\\* /\\* (.+) \\*/"
+ options:NSRegularExpressionCaseInsensitive
+ error:nil];
+ _dictPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\* /\\* (.+?), (.+) \\*/"
+ options:NSRegularExpressionCaseInsensitive
+ error:nil];
+ _dictModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSDictionary\\<(.+?), (.+)*\\>"
+ options:NSRegularExpressionCaseInsensitive
+ error:nil];
+ }
+ return self;
+}
+
+#pragma mark - Deserialize methods
+
+- (id) deserialize:(id) data class:(NSString *) className error:(NSError **) error {
+ // return nil if data is nil or className is nil
+ if (!data || !className || [data isKindOfClass:[NSNull class]]) {
+ return nil;
+ }
+
+ // remove "*" from className, if ends with "*"
+ if ([className hasSuffix:@"*"]) {
+ className = [className substringToIndex:[className length] - 1];
+ }
+ // pure object
+ if ([self.basicReturnTypes containsObject:className]) {
+ return data;
+ }
+
+ // primitives
+ if ([self.primitiveTypes containsObject:className]) {
+ return [self deserializePrimitiveValue:data class:className error:error];
+ }
+
+ NSTextCheckingResult *match = nil;
+ NSRange range = NSMakeRange(0, [className length]);
+ // list of models
+ match = [self.arrayOfModelsPatExpression firstMatchInString:className options:0 range:range];
+ if (match) {
+ NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
+ return [self deserializeArrayValue:data innerType:innerType error:error];
+ }
+
+ // list of primitives
+ match = [self.arrayOfPrimitivesPatExpression firstMatchInString:className options:0 range:range];
+ if (match) {
+ NSString *innerType = [className substringWithRange:[match rangeAtIndex:1]];
+ return [self deserializeArrayValue:data innerType:innerType error:error];
+ }
+
+ // map
+ match = [self.dictPatExpression firstMatchInString:className options:0 range:range];
+ if (match) {
+ NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
+ return [self deserializeDictionaryValue:data valueType:valueType error:error];
+ }
+
+ match = [self.dictModelsPatExpression firstMatchInString:className options:0 range:range];
+ if (match) {
+ NSString *valueType = [className substringWithRange:[match rangeAtIndex:2]];
+ return [self deserializeDictionaryValue:data valueType:valueType error:error];
+ }
+
+ // model
+ Class ModelClass = NSClassFromString(className);
+ if ([ModelClass instancesRespondToSelector:@selector(initWithDictionary:error:)]) {
+ return [(JSONModel *) [ModelClass alloc] initWithDictionary:data error:error];
+ }
+
+ if(error) {
+ *error = [self unknownResponseErrorWithExpectedType:className data:data];
+ }
+ return nil;
+}
+
+- (id) deserializeDictionaryValue:(id) data valueType:(NSString *) valueType error:(NSError**)error {
+ if(![data isKindOfClass: [NSDictionary class]]) {
+ if(error) {
+ *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDictionary class]) data:data];
+ }
+ return nil;
+ }
+ __block NSMutableDictionary *resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]];
+ for (id key in [data allKeys]) {
+ id obj = [data valueForKey:key];
+ id dicObj = [self deserialize:obj class:valueType error:error];
+ if(dicObj) {
+ [resultDict setValue:dicObj forKey:key];
+ } else if([obj isKindOfClass:[NSNull class]]) {
+ if(self.treatNullAsError) {
+ if (error) {
+ *error = [self emptyValueOccurredError];
+ }
+ resultDict = nil;
+ break;
+ }
+ } else {
+ resultDict = nil;
+ break;
+ }
+ }
+ return resultDict;
+}
+
+- (id) deserializeArrayValue:(id) data innerType:(NSString *) innerType error:(NSError**)error {
+ if(![data isKindOfClass: [NSArray class]]) {
+ if(error) {
+ *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSArray class]) data:data];
+ }
+ return nil;
+ }
+ NSMutableArray* resultArray = [NSMutableArray arrayWithCapacity:[data count]];
+ for (id obj in data) {
+ id arrObj = [self deserialize:obj class:innerType error:error];
+ if(arrObj) {
+ [resultArray addObject:arrObj];
+ } else if([obj isKindOfClass:[NSNull class]]) {
+ if(self.treatNullAsError) {
+ if (error) {
+ *error = [self emptyValueOccurredError];
+ }
+ resultArray = nil;
+ break;
+ }
+ } else {
+ resultArray = nil;
+ break;
+ }
+ }
+ return resultArray;
+};
+
+- (id) deserializePrimitiveValue:(id) data class:(NSString *) className error:(NSError**)error {
+ if ([className isEqualToString:@"NSString"]) {
+ return [NSString stringWithString:data];
+ }
+ else if ([className isEqualToString:@"NSDate"]) {
+ return [self deserializeDateValue:data error:error];
+ }
+ else if ([className isEqualToString:@"NSNumber"]) {
+ // NSNumber from NSNumber
+ if ([data isKindOfClass:[NSNumber class]]) {
+ return data;
+ }
+ else if ([data isKindOfClass:[NSString class]]) {
+ // NSNumber (NSCFBoolean) from NSString
+ if ([[data lowercaseString] isEqualToString:@"true"] || [[data lowercaseString] isEqualToString:@"false"]) {
+ return @([data boolValue]);
+ // NSNumber from NSString
+ } else {
+ NSNumber* formattedValue = [self.numberFormatter numberFromString:data];
+ if(!formattedValue && [data length] > 0 && error) {
+ *error = [self typeMismatchErrorWithExpectedType:className data:data];
+ }
+ return formattedValue;
+ }
+ }
+ }
+ if(error) {
+ *error = [self typeMismatchErrorWithExpectedType:className data:data];
+ }
+ return nil;
+}
+
+- (id) deserializeDateValue:(id) data error:(NSError**)error {
+ NSDate *date =[NSDate dateWithISO8601String:data];
+ if(!date && [data length] > 0 && error) {
+ *error = [self typeMismatchErrorWithExpectedType:NSStringFromClass([NSDate class]) data:data];
+ }
+ return date;
+};
+
+-(NSError *)typeMismatchErrorWithExpectedType:(NSString *)expected data:(id)data {
+ NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Received response [%@] is not an object of type %@",nil),data, expected];
+ NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
+ return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGTypeMismatchErrorCode userInfo:userInfo];
+}
+
+-(NSError *)emptyValueOccurredError {
+ NSString * message = NSLocalizedString(@"Received response contains null value in dictionary or array response",nil);
+ NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
+ return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGEmptyValueOccurredErrorCode userInfo:userInfo];
+}
+
+-(NSError *)unknownResponseErrorWithExpectedType:(NSString *)expected data:(id)data {
+ NSString * message = [NSString stringWithFormat:NSLocalizedString(@"Unknown response expected type %@ [reponse: %@]",nil),expected,data];
+ NSDictionary * userInfo = @{NSLocalizedDescriptionKey : message};
+ return [NSError errorWithDomain:SWGDeserializationErrorDomainKey code:SWGUnknownResponseObjectErrorCode userInfo:userInfo];
+}
+
+@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGReturn.h b/samples/client/petstore/objc/SwaggerClient/SWGReturn.h
deleted file mode 100644
index fcce78f3681..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGReturn.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#import
-#import "SWGObject.h"
-
-/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-
-
-
-@protocol SWGReturn
-@end
-
-@interface SWGReturn : SWGObject
-
-
-@property(nonatomic) NSNumber* _return;
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGReturn.m b/samples/client/petstore/objc/SwaggerClient/SWGReturn.m
deleted file mode 100644
index ad97f1b15e9..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGReturn.m
+++ /dev/null
@@ -1,51 +0,0 @@
-#import "SWGReturn.h"
-
-@implementation SWGReturn
-
-- (instancetype)init {
- self = [super init];
-
- if (self) {
- // initalise property's default value, if any
-
- }
-
- return self;
-}
-
-
-/**
- * Maps json key to property name.
- * This method is used by `JSONModel`.
- */
-+ (JSONKeyMapper *)keyMapper
-{
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"return": @"_return" }];
-}
-
-/**
- * Indicates whether the property with the given name is optional.
- * If `propertyName` is optional, then return `YES`, otherwise return `NO`.
- * This method is used by `JSONModel`.
- */
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
- NSArray *optionalProperties = @[@"_return"];
-
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
-}
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.h b/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.h
new file mode 100644
index 00000000000..5803999f362
--- /dev/null
+++ b/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.h
@@ -0,0 +1,29 @@
+#import
+
+/**
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * Do not edit the class manually.
+ */
+
+@protocol SWGSanitizer
+
+/**
+ * Sanitize object for request
+ *
+ * @param object The query/path/header/form/body param to be sanitized.
+ */
+- (id) sanitizeForSerialization:(id) object;
+
+/**
+ * Convert parameter to NSString
+ */
+- (NSString *) parameterToString: (id) param;
+
+@end
+
+@interface SWGSanitizer : NSObject
+
+
+
+@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.m b/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.m
new file mode 100644
index 00000000000..3f1dea7726e
--- /dev/null
+++ b/samples/client/petstore/objc/SwaggerClient/SWGSanitizer.m
@@ -0,0 +1,82 @@
+#import "SWGSanitizer.h"
+#import "SWGObject.h"
+#import "SWGQueryParamCollection.h"
+#import
+
+@interface SWGSanitizer ()
+
+@end
+
+@implementation SWGSanitizer
+
+- (id) sanitizeForSerialization:(id) object {
+ if (object == nil) {
+ return nil;
+ }
+ else if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]] || [object isKindOfClass:[SWGQueryParamCollection class]]) {
+ return object;
+ }
+ else if ([object isKindOfClass:[NSDate class]]) {
+ return [object ISO8601String];
+ }
+ else if ([object isKindOfClass:[NSArray class]]) {
+ NSArray *objectArray = object;
+ NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]];
+ [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ id sanitizedObj = [self sanitizeForSerialization:obj];
+ if (sanitizedObj) {
+ [sanitizedObjs addObject:sanitizedObj];
+ }
+ }];
+ return sanitizedObjs;
+ }
+ else if ([object isKindOfClass:[NSDictionary class]]) {
+ NSDictionary *objectDict = object;
+ NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]];
+ [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+ id sanitizedObj = [self sanitizeForSerialization:obj];
+ if (sanitizedObj) {
+ sanitizedObjs[key] = sanitizedObj;
+ }
+ }];
+ return sanitizedObjs;
+ }
+ else if ([object isKindOfClass:[SWGObject class]]) {
+ return [object toDictionary];
+ }
+ else {
+ NSException *e = [NSException
+ exceptionWithName:@"InvalidObjectArgumentException"
+ reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", object]
+ userInfo:nil];
+ @throw e;
+ }
+}
+
+- (NSString *) parameterToString:(id)param {
+ if ([param isKindOfClass:[NSString class]]) {
+ return param;
+ }
+ else if ([param isKindOfClass:[NSNumber class]]) {
+ return [param stringValue];
+ }
+ else if ([param isKindOfClass:[NSDate class]]) {
+ return [param ISO8601String];
+ }
+ else if ([param isKindOfClass:[NSArray class]]) {
+ NSMutableArray *mutableParam = [NSMutableArray array];
+ [param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ [mutableParam addObject:[self parameterToString:obj]];
+ }];
+ return [mutableParam componentsJoinedByString:@","];
+ }
+ else {
+ NSException *e = [NSException
+ exceptionWithName:@"InvalidObjectArgumentException"
+ reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param]
+ userInfo:nil];
+ @throw e;
+ }
+}
+
+@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h b/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h
deleted file mode 100644
index 88187b28877..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#import
-#import "SWGObject.h"
-
-/**
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen
- * Do not edit the class manually.
- */
-
-
-
-@protocol SWGSpecialModelName_
-@end
-
-@interface SWGSpecialModelName_ : SWGObject
-
-
-@property(nonatomic) NSNumber* specialPropertyName;
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m b/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m
deleted file mode 100644
index 9e1e680787d..00000000000
--- a/samples/client/petstore/objc/SwaggerClient/SWGSpecialModelName_.m
+++ /dev/null
@@ -1,51 +0,0 @@
-#import "SWGSpecialModelName_.h"
-
-@implementation SWGSpecialModelName_
-
-- (instancetype)init {
- self = [super init];
-
- if (self) {
- // initalise property's default value, if any
-
- }
-
- return self;
-}
-
-
-/**
- * Maps json key to property name.
- * This method is used by `JSONModel`.
- */
-+ (JSONKeyMapper *)keyMapper
-{
- return [[JSONKeyMapper alloc] initWithDictionary:@{ @"$special[property.name]": @"specialPropertyName" }];
-}
-
-/**
- * Indicates whether the property with the given name is optional.
- * If `propertyName` is optional, then return `YES`, otherwise return `NO`.
- * This method is used by `JSONModel`.
- */
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
- NSArray *optionalProperties = @[@"specialPropertyName"];
-
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
-}
-
-@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h
index 0a7bc70864a..d86eb23a046 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h
+++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h
@@ -39,9 +39,9 @@
///
///
///
-/// @return NSDictionary* /* NSString, NSNumber */
+/// @return NSDictionary*
-(NSNumber*) getInventoryWithCompletionHandler:
- (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler;
+ (void (^)(NSDictionary* output, NSError* error)) handler;
///
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m
index 84cd3a699d0..336258c3c5b 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m
@@ -141,10 +141,10 @@ static SWGStoreApi* singletonAPI = nil;
///
/// Returns pet inventories by status
/// Returns a map of status codes to quantities
-/// @returns NSDictionary* /* NSString, NSNumber */
+/// @returns NSDictionary*
///
-(NSNumber*) getInventoryWithCompletionHandler:
- (void (^)(NSDictionary* /* NSString, NSNumber */ output, NSError* error)) handler {
+ (void (^)(NSDictionary* output, NSError* error)) handler {
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"/store/inventory"];
// remove format in URL if needed
@@ -192,9 +192,9 @@ static SWGStoreApi* singletonAPI = nil;
authSettings: authSettings
requestContentType: requestContentType
responseContentType: responseContentType
- responseType: @"NSDictionary* /* NSString, NSNumber */"
+ responseType: @"NSDictionary*"
completionBlock: ^(id data, NSError *error) {
- handler((NSDictionary* /* NSString, NSNumber */)data, error);
+ handler((NSDictionary*)data, error);
}
];
}
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m
index 9eb00a157e3..8ad1742750d 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m
@@ -4,12 +4,10 @@
- (instancetype)init {
self = [super init];
-
if (self) {
// initalise property's default value, if any
}
-
return self;
}
@@ -18,8 +16,7 @@
* Maps json key to property name.
* This method is used by `JSONModel`.
*/
-+ (JSONKeyMapper *)keyMapper
-{
++ (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }];
}
@@ -28,24 +25,11 @@
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
* This method is used by `JSONModel`.
*/
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
++ (BOOL)propertyIsOptional:(NSString *)propertyName {
+
NSArray *optionalProperties = @[@"_id", @"name"];
+ return [optionalProperties containsObject:propertyName];
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
}
@end
diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m
index 2445dd37854..2551108cb5f 100644
--- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m
+++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m
@@ -4,12 +4,10 @@
- (instancetype)init {
self = [super init];
-
if (self) {
// initalise property's default value, if any
}
-
return self;
}
@@ -18,8 +16,7 @@
* Maps json key to property name.
* This method is used by `JSONModel`.
*/
-+ (JSONKeyMapper *)keyMapper
-{
++ (JSONKeyMapper *)keyMapper {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }];
}
@@ -28,24 +25,11 @@
* If `propertyName` is optional, then return `YES`, otherwise return `NO`.
* This method is used by `JSONModel`.
*/
-+ (BOOL)propertyIsOptional:(NSString *)propertyName
-{
++ (BOOL)propertyIsOptional:(NSString *)propertyName {
+
NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"];
+ return [optionalProperties containsObject:propertyName];
- if ([optionalProperties containsObject:propertyName]) {
- return YES;
- }
- else {
- return NO;
- }
-}
-
-/**
- * Gets the string presentation of the object.
- * This method will be called when logging model object using `NSLog`.
- */
-- (NSString *)description {
- return [[self toDictionary] description];
}
@end
diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m
index 57fd9828e03..4405438e7ee 100644
--- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m
+++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m
@@ -27,16 +27,11 @@
SWGPetApi *api = [[SWGPetApi alloc] init];
NSURL *file = [NSURL fileURLWithPath:@"/Users/geekerzp/tmp/test.jpg"];
- [api uploadFileWithPetId:@2 additionalMetadata:@2 file:file completionHandler:^(NSError *error) {
+ [api uploadFileWithPetId:@2 additionalMetadata:@"2" file:file completionHandler:^(NSError *error) {
NSLog(@"*** error: %@", error);
}];
}
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
-}
-
- (SWGPet*) createPet {
SWGPet * pet = [[SWGPet alloc] init];
pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]];
diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m
index 5f5d274b4b0..6077ab42981 100644
--- a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m
+++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m
@@ -27,11 +27,28 @@
[formatter setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [formatter dateFromString:dateStr];
NSError* error;
- NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*" error:&error];
+ NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error];
XCTAssertNil(error);
XCTAssertEqualWithAccuracy([date timeIntervalSinceReferenceDate], [deserializedDate timeIntervalSinceReferenceDate], 0.001);
}
+- (void)testDeserializeInvalidDate {
+ NSString *dateStr = @"random string";
+
+ NSError* error;
+ NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error];
+ XCTAssertNotNil(error);
+ XCTAssertNil(deserializedDate);
+}
+
+- (void)testDeserializeEmptyDate {
+ NSString *dateStr = @"";
+ NSError* error;
+ NSDate *deserializedDate = [apiClient.responseDeserializer deserialize:dateStr class:@"NSDate*" error:&error];
+ XCTAssertNil(error);
+ XCTAssertNil(deserializedDate);
+}
+
- (void)testDeserializeDateTime {
NSString *dateTimeStr = @"1997-07-16T19:20:30+00:00";
@@ -39,15 +56,23 @@
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *dateTime = [formatter dateFromString:dateTimeStr];
NSError* error;
- NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*" error:&error];
+ NSDate *deserializedDateTime = [apiClient.responseDeserializer deserialize:dateTimeStr class:@"NSDate*" error:&error];
XCTAssertNil(error);
XCTAssertEqualWithAccuracy([dateTime timeIntervalSinceReferenceDate], [deserializedDateTime timeIntervalSinceReferenceDate], 0.001);
}
+- (void)testDeserializeUnknownObject {
+ NSString *data = @"random string";
+ NSError* error;
+ NSNumber *result = [apiClient.responseDeserializer deserialize:data class:@"DeserializationTest*" error:&error];
+ XCTAssertNotNil(error);
+ XCTAssertNil(result);
+}
+
- (void)testDeserializeObject {
NSNumber *data = @1;
NSError* error;
- NSNumber *result = [apiClient deserialize:data class:@"NSObject*" error:&error];
+ NSNumber *result = [apiClient.responseDeserializer deserialize:data class:@"NSObject*" error:&error];
XCTAssertNil(error);
XCTAssertEqualObjects(data, result);
}
@@ -55,7 +80,7 @@
- (void)testDeserializeString {
NSString *data = @"test string";
NSError* error;
- NSString *result = [apiClient deserialize:data class:@"NSString*" error:&error];
+ NSString *result = [apiClient.responseDeserializer deserialize:data class:@"NSString*" error:&error];
XCTAssertNil(error);
XCTAssertTrue([result isEqualToString:data]);
}
@@ -63,12 +88,29 @@
- (void)testDeserializeListOfString {
NSArray *data = @[@"test string"];
NSError* error;
- NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSString */" error:&error];
+ NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error];
XCTAssertNil(error);
XCTAssertTrue([result isKindOfClass:[NSArray class]]);
XCTAssertTrue([result[0] isKindOfClass:[NSString class]]);
}
+- (void)testDeserializeInvalidListOfNumbers {
+ NSArray *data = @[@"test string"];
+ NSError* error;
+ NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error];
+ XCTAssertNotNil(error);
+ XCTAssertNil(result);
+}
+
+- (void)testDeserializeListOfNumbers {
+ NSArray *data = @[@"1.0"];
+ NSError* error;
+ NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error];
+ XCTAssertNil(error);
+ XCTAssertTrue([result isKindOfClass:[NSArray class]]);
+ XCTAssertTrue([result[0] isKindOfClass:[NSNumber class]]);
+}
+
- (void)testDeserializeListOfModels {
NSArray *data =
@[
@@ -92,11 +134,17 @@
}];
NSError* error;
- NSArray *result = [apiClient deserialize:data class:@"NSArray*" error:&error];
+ NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray*" error:&error];
XCTAssertTrue([result isKindOfClass:[NSArray class]]);
XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]);
- XCTAssertEqualObjects([[result firstObject] _id], @119);
+ SWGPet*pet = [result firstObject];
+ XCTAssertEqualObjects([pet.photoUrls firstObject],@"string");
+ XCTAssertTrue([[pet.tags firstObject] isKindOfClass:[SWGTag class]]);
+ SWGTag* tag = [pet.tags firstObject];
+ XCTAssertEqualObjects(tag._id, @0);
+ XCTAssertEqualObjects(tag.name, @"string");
+ XCTAssertEqualObjects(pet._id, @119);
}
- (void)testDeserializeMapOfModels {
@@ -123,7 +171,7 @@
}
};
NSError* error;
- NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error];
+ NSDictionary *result = [apiClient.responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, SWGPet */" error:&error];
XCTAssertTrue([result isKindOfClass:[NSDictionary class]]);
XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]);
@@ -134,11 +182,44 @@
NSDictionary *data =
@{
@"foo": @{
- @"bar": @1
+ @"bar": @1,
+ @"bar2": [NSNull null]
}
};
+ SWGResponseDeserializer* responseDeserializer = [[SWGResponseDeserializer alloc] init];
NSError* error;
- NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error];
+ NSDictionary *result = [responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error];
+
+ XCTAssertTrue([result isKindOfClass:[NSDictionary class]]);
+ XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]);
+ XCTAssertTrue([result[@"foo"][@"bar"] isKindOfClass:[NSNumber class]]);
+}
+
+
+- (void)testDeserializeNestedMapWithNullValue {
+ NSDictionary *data =
+ @{
+ @"foo": @{
+ @"bar": @1,
+ @"bar2": [NSNull null]
+ }
+ };
+ SWGResponseDeserializer* responseDeserializer = [[SWGResponseDeserializer alloc] init];
+ responseDeserializer.treatNullAsError = YES;
+ NSError* error;
+ NSDictionary *result = [responseDeserializer deserialize:data class:@"NSDictionary* /* NSString, NSDictionary* /* NSString, NSNumber */ */" error:&error];
+ XCTAssertNil(result);
+ XCTAssertNotNil(error);
+}
+
+- (void)testDeserializeNestedMap2 {
+ NSDictionary *data = @{
+ @"foo": @{
+ @"bar": @1
+ }
+ };
+ NSError* error;
+ NSDictionary *result = [apiClient.responseDeserializer deserialize:data class:@"NSDictionary*>*" error:&error];
XCTAssertTrue([result isKindOfClass:[NSDictionary class]]);
XCTAssertTrue([result[@"foo"] isKindOfClass:[NSDictionary class]]);
@@ -148,7 +229,7 @@
- (void)testDeserializeNestedList {
NSArray *data = @[@[@"foo"]];
NSError* error;
- NSArray *result = [apiClient deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error];
+ NSArray *result = [apiClient.responseDeserializer deserialize:data class:@"NSArray* /* NSArray* /* NSString */ */" error:&error];
XCTAssertTrue([result isKindOfClass:[NSArray class]]);
XCTAssertTrue([result[0] isKindOfClass:[NSArray class]]);
@@ -161,11 +242,11 @@
data = @"true";
NSError* error;
- result = [apiClient deserialize:data class:@"NSNumber*" error:&error];
+ result = [apiClient.responseDeserializer deserialize:data class:@"NSNumber*" error:&error];
XCTAssertTrue([result isEqual:@YES]);
data = @"false";
- result = [apiClient deserialize:data class:@"NSNumber*" error:&error];
+ result = [apiClient.responseDeserializer deserialize:data class:@"NSNumber*" error:&error];
XCTAssertTrue([result isEqual:@NO]);
}
diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m
index 7fd3d4f97c8..7ddc817e9ef 100644
--- a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m
+++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetApiTest.m
@@ -165,7 +165,7 @@ which causes an exception when deserializing the data
SWGTag* tag = [[SWGTag alloc] init];
tag.name = @"tony";
NSLog(@"%@", pet._id);
- pet.tags = [[NSArray alloc] initWithObjects:tag, nil];
+ pet.tags = (id)[[NSArray alloc] initWithObjects:tag, nil];
[api addPetWithBody:pet completionHandler:^(NSError *error) {
if(error) {
diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m
index e9f1a46af3b..ed87d8f9e2d 100644
--- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m
+++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m
@@ -2,11 +2,6 @@
#import
#import
#import
-#import
-#import
-#import
-#import
-#import
@interface SWGApiClientTest : XCTestCase
@@ -109,31 +104,31 @@
// nil
data = nil;
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
// NSString
data = @"test string";
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
// NSNumber
data = @1;
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
// SWGQueryParamCollection
data = [[SWGQueryParamCollection alloc] init];
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
// NSDate
data = [NSDate dateWithISO8601String:@"1997-07-16T19:20:30.45+01:00"];
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, [data ISO8601String]);
data = [NSDate dateWithISO8601String:@"1997-07-16"];
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, [data ISO8601String]);
// model
@@ -144,23 +139,23 @@
@"status": @"available",
@"photoUrls": @[@"http://foo.bar.com/3", @"http://foo.bar.com/4"]};
data = [[SWGPet alloc] initWithDictionary:petDict error:nil];
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, petDict);
// NSArray
data = @[@1];
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
// NSArray of models
NSArray *arrayOfPetDict = @[petDict];
- data = [NSArray arrayWithObject:[[SWGPet alloc] initWithDictionary:petDict error:nil]];
- result = [self.apiClient sanitizeForSerialization:data];
+ data = @[[[SWGPet alloc] initWithDictionary:petDict error:nil]];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, arrayOfPetDict);
// NSDictionary
data = @{@"test key": @"test value"};
- result = [self.apiClient sanitizeForSerialization:data];
+ result = [self.apiClient.sanitizer sanitizeForSerialization:data];
XCTAssertEqualObjects(result, data);
}
diff --git a/samples/client/petstore/objc/docs/SWGPet.md b/samples/client/petstore/objc/docs/SWGPet.md
index 6c7286531f9..c8298c66bf1 100644
--- a/samples/client/petstore/objc/docs/SWGPet.md
+++ b/samples/client/petstore/objc/docs/SWGPet.md
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
**_id** | **NSNumber*** | | [optional]
**category** | [**SWGCategory***](SWGCategory.md) | | [optional]
**name** | **NSString*** | |
-**photoUrls** | **NSArray* /* NSString */** | |
+**photoUrls** | **NSArray<NSString*>*** | |
**tags** | [**NSArray<SWGTag>***](SWGTag.md) | | [optional]
**status** | **NSString*** | pet status in the store | [optional]
diff --git a/samples/client/petstore/objc/docs/SWGPetApi.md b/samples/client/petstore/objc/docs/SWGPetApi.md
index 78a54942c2f..a07f0cf067c 100644
--- a/samples/client/petstore/objc/docs/SWGPetApi.md
+++ b/samples/client/petstore/objc/docs/SWGPetApi.md
@@ -140,7 +140,7 @@ void (empty response body)
# **findPetsByStatus**
```objc
--(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status
+-(NSNumber*) findPetsByStatusWithStatus: (NSArray*) status
completionHandler: (void (^)(NSArray* output, NSError* error)) handler;
```
@@ -156,7 +156,7 @@ SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig];
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
-NSArray* /* NSString */ status = @[@"available"]; // Status values that need to be considered for filter (optional) (default to available)
+NSArray* status = @[@"available"]; // Status values that need to be considered for filter (optional) (default to available)
@try
{
@@ -184,7 +184,7 @@ NSArray* /* NSString */ status = @[@"available"]; // Status values that need to
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **status** | [**NSArray* /* NSString */**](NSString*.md)| Status values that need to be considered for filter | [optional] [default to available]
+ **status** | [**NSArray<NSString*>***](NSString*.md)| Status values that need to be considered for filter | [optional] [default to available]
### Return type
@@ -203,7 +203,7 @@ Name | Type | Description | Notes
# **findPetsByTags**
```objc
--(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags
+-(NSNumber*) findPetsByTagsWithTags: (NSArray*) tags
completionHandler: (void (^)(NSArray* output, NSError* error)) handler;
```
@@ -219,7 +219,7 @@ SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig];
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
-NSArray* /* NSString */ tags = @[@"tags_example"]; // Tags to filter by (optional)
+NSArray