mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 09:16:11 +00:00
Merge branch 'master' into new-sync-master-to-2.3.0
This commit is contained in:
@@ -14,18 +14,18 @@
|
||||
(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['superagent'], factory);
|
||||
define(['superagent', 'querystring'], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
// CommonJS-like environments that support module.exports, like Node.
|
||||
module.exports = factory(require('superagent'));
|
||||
module.exports = factory(require('superagent'), require('querystring'));
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
if (!root.SwaggerPetstore) {
|
||||
root.SwaggerPetstore = {};
|
||||
}
|
||||
root.SwaggerPetstore.ApiClient = factory(root.superagent);
|
||||
root.SwaggerPetstore.ApiClient = factory(root.superagent, root.querystring);
|
||||
}
|
||||
}(this, function(superagent) {
|
||||
}(this, function(superagent, querystring) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -78,6 +78,22 @@
|
||||
* @default true
|
||||
*/
|
||||
this.cache = true;
|
||||
|
||||
/**
|
||||
* If set to true, the client will save the cookies from each server
|
||||
* response, and return them in the next request.
|
||||
* @default false
|
||||
*/
|
||||
this.enableCookies = false;
|
||||
|
||||
/*
|
||||
* Used to save and return cookies in a node.js (non-browser) setting,
|
||||
* if this.enableCookies is set to true.
|
||||
*/
|
||||
if (typeof window === 'undefined') {
|
||||
this.agent = new superagent.agent();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -406,7 +422,7 @@
|
||||
}
|
||||
|
||||
if (contentType === 'application/x-www-form-urlencoded') {
|
||||
request.send(this.normalizeParams(formParams));
|
||||
request.send(querystring.stringify(this.normalizeParams(formParams)));
|
||||
} else if (contentType == 'multipart/form-data') {
|
||||
var _formParams = this.normalizeParams(formParams);
|
||||
for (var key in _formParams) {
|
||||
@@ -428,6 +444,16 @@
|
||||
request.accept(accept);
|
||||
}
|
||||
|
||||
// Attach previously saved cookies, if enabled
|
||||
if (this.enableCookies){
|
||||
if (typeof window === 'undefined') {
|
||||
this.agent.attachCookies(request);
|
||||
}
|
||||
else {
|
||||
request.withCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
request.end(function(error, response) {
|
||||
if (callback) {
|
||||
@@ -435,6 +461,9 @@
|
||||
if (!error) {
|
||||
try {
|
||||
data = _this.deserialize(response, returnType);
|
||||
if (_this.enableCookies && typeof window === 'undefined'){
|
||||
_this.agent.saveCookies(response);
|
||||
}
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
@@ -462,9 +491,12 @@
|
||||
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
||||
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
||||
* all properties on <code>data<code> will be converted to this type.
|
||||
* @returns An instance of the specified type.
|
||||
* @returns An instance of the specified type or null or undefined if data is null or undefined.
|
||||
*/
|
||||
exports.convertToType = function(data, type) {
|
||||
if (data === null || data === undefined)
|
||||
return data
|
||||
|
||||
switch (type) {
|
||||
case 'Boolean':
|
||||
return Boolean(data);
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling testClientModel");
|
||||
}
|
||||
|
||||
@@ -125,22 +125,22 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter '_number' is set
|
||||
if (_number == undefined || _number == null) {
|
||||
if (_number === undefined || _number === null) {
|
||||
throw new Error("Missing the required parameter '_number' when calling testEndpointParameters");
|
||||
}
|
||||
|
||||
// verify the required parameter '_double' is set
|
||||
if (_double == undefined || _double == null) {
|
||||
if (_double === undefined || _double === null) {
|
||||
throw new Error("Missing the required parameter '_double' when calling testEndpointParameters");
|
||||
}
|
||||
|
||||
// verify the required parameter 'patternWithoutDelimiter' is set
|
||||
if (patternWithoutDelimiter == undefined || patternWithoutDelimiter == null) {
|
||||
if (patternWithoutDelimiter === undefined || patternWithoutDelimiter === null) {
|
||||
throw new Error("Missing the required parameter 'patternWithoutDelimiter' when calling testEndpointParameters");
|
||||
}
|
||||
|
||||
// verify the required parameter '_byte' is set
|
||||
if (_byte == undefined || _byte == null) {
|
||||
if (_byte === undefined || _byte === null) {
|
||||
throw new Error("Missing the required parameter '_byte' when calling testEndpointParameters");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling addPet");
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == undefined || petId == null) {
|
||||
if (petId === undefined || petId === null) {
|
||||
throw new Error("Missing the required parameter 'petId' when calling deletePet");
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'status' is set
|
||||
if (status == undefined || status == null) {
|
||||
if (status === undefined || status === null) {
|
||||
throw new Error("Missing the required parameter 'status' when calling findPetsByStatus");
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'tags' is set
|
||||
if (tags == undefined || tags == null) {
|
||||
if (tags === undefined || tags === null) {
|
||||
throw new Error("Missing the required parameter 'tags' when calling findPetsByTags");
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == undefined || petId == null) {
|
||||
if (petId === undefined || petId === null) {
|
||||
throw new Error("Missing the required parameter 'petId' when calling getPetById");
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling updatePet");
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == undefined || petId == null) {
|
||||
if (petId === undefined || petId === null) {
|
||||
throw new Error("Missing the required parameter 'petId' when calling updatePetWithForm");
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == undefined || petId == null) {
|
||||
if (petId === undefined || petId === null) {
|
||||
throw new Error("Missing the required parameter 'petId' when calling uploadFile");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == undefined || orderId == null) {
|
||||
if (orderId === undefined || orderId === null) {
|
||||
throw new Error("Missing the required parameter 'orderId' when calling deleteOrder");
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == undefined || orderId == null) {
|
||||
if (orderId === undefined || orderId === null) {
|
||||
throw new Error("Missing the required parameter 'orderId' when calling getOrderById");
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling placeOrder");
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling createUser");
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling createUsersWithArrayInput");
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling createUsersWithListInput");
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == undefined || username == null) {
|
||||
if (username === undefined || username === null) {
|
||||
throw new Error("Missing the required parameter 'username' when calling deleteUser");
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == undefined || username == null) {
|
||||
if (username === undefined || username === null) {
|
||||
throw new Error("Missing the required parameter 'username' when calling getUserByName");
|
||||
}
|
||||
|
||||
@@ -298,12 +298,12 @@
|
||||
var postBody = null;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == undefined || username == null) {
|
||||
if (username === undefined || username === null) {
|
||||
throw new Error("Missing the required parameter 'username' when calling loginUser");
|
||||
}
|
||||
|
||||
// verify the required parameter 'password' is set
|
||||
if (password == undefined || password == null) {
|
||||
if (password === undefined || password === null) {
|
||||
throw new Error("Missing the required parameter 'password' when calling loginUser");
|
||||
}
|
||||
|
||||
@@ -392,12 +392,12 @@
|
||||
var postBody = body;
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == undefined || username == null) {
|
||||
if (username === undefined || username === null) {
|
||||
throw new Error("Missing the required parameter 'username' when calling updateUser");
|
||||
}
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == undefined || body == null) {
|
||||
if (body === undefined || body === null) {
|
||||
throw new Error("Missing the required parameter 'body' when calling updateUser");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user