forked from loafle/openapi-generator-original
Merge pull request #2287 from vzeman/issue-2275
Add option to set request timeout for Javascript request
This commit is contained in:
commit
ab98f1a39d
@ -31,6 +31,11 @@
|
||||
* The default HTTP headers to be included for all API calls.
|
||||
*/
|
||||
this.defaultHeaders = {};
|
||||
|
||||
/**
|
||||
* The default HTTP timeout for all API calls.
|
||||
*/
|
||||
this.timeout = 60000;
|
||||
};
|
||||
|
||||
ApiClient.prototype.paramToString = function paramToString(param) {
|
||||
@ -231,6 +236,9 @@
|
||||
// set header parameters
|
||||
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
|
||||
|
||||
//set request timeout
|
||||
request.timeout(this.timeout);
|
||||
|
||||
var contentType = this.jsonPreferredMime(contentTypes);
|
||||
if (contentType) {
|
||||
request.type(contentType);
|
||||
|
@ -22,18 +22,23 @@
|
||||
this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, '');
|
||||
|
||||
this.authentications = {
|
||||
'petstore_auth': {type: 'oauth2'},
|
||||
'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'},
|
||||
'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'},
|
||||
'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'},
|
||||
'api_key': {type: 'apiKey', in: 'header', name: 'api_key'},
|
||||
'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'},
|
||||
'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'},
|
||||
'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'},
|
||||
'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'}
|
||||
'petstore_auth': {type: 'oauth2'}
|
||||
};
|
||||
|
||||
/**
|
||||
* The default HTTP headers to be included for all API calls.
|
||||
*/
|
||||
this.defaultHeaders = {};
|
||||
|
||||
/**
|
||||
* The default HTTP timeout for all API calls.
|
||||
*/
|
||||
this.timeout = 60000;
|
||||
};
|
||||
|
||||
ApiClient.prototype.paramToString = function paramToString(param) {
|
||||
@ -234,6 +239,9 @@
|
||||
// set header parameters
|
||||
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
|
||||
|
||||
//set request timeout
|
||||
request.timeout(this.timeout);
|
||||
|
||||
var contentType = this.jsonPreferredMime(contentTypes);
|
||||
if (contentType) {
|
||||
request.type(contentType);
|
||||
|
@ -89,8 +89,8 @@
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
* @param {[String]} opts['status'] Status values that need to be considered for filter
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @param {[String]} opts['status'] Status values that need to be considered for query
|
||||
* @param {function} callback the callback function, accepting three arguments: error, data, response
|
||||
* data is of type: [Pet]
|
||||
*/
|
||||
@ -183,7 +183,7 @@
|
||||
var formParams = {
|
||||
};
|
||||
|
||||
var authNames = ['petstore_auth', 'api_key'];
|
||||
var authNames = ['api_key', 'petstore_auth'];
|
||||
var contentTypes = [];
|
||||
var accepts = ['application/json', 'application/xml'];
|
||||
var returnType = Pet;
|
||||
@ -349,7 +349,7 @@
|
||||
var formParams = {
|
||||
};
|
||||
|
||||
var authNames = ['petstore_auth', 'api_key'];
|
||||
var authNames = ['api_key', 'petstore_auth'];
|
||||
var contentTypes = [];
|
||||
var accepts = ['application/json', 'application/xml'];
|
||||
var returnType = 'String';
|
||||
|
@ -21,6 +21,41 @@
|
||||
var self = this;
|
||||
|
||||
|
||||
/**
|
||||
* Finds orders by status
|
||||
* A single status value can be provided as a string
|
||||
* @param {String} opts['status'] Status value that needs to be considered for query
|
||||
* @param {function} callback the callback function, accepting three arguments: error, data, response
|
||||
* data is of type: [Order]
|
||||
*/
|
||||
self.findOrdersByStatus = function(opts, callback) {
|
||||
opts = opts || {};
|
||||
var postBody = null;
|
||||
|
||||
|
||||
var pathParams = {
|
||||
};
|
||||
var queryParams = {
|
||||
'status': opts['status']
|
||||
};
|
||||
var headerParams = {
|
||||
};
|
||||
var formParams = {
|
||||
};
|
||||
|
||||
var authNames = ['test_api_client_id', 'test_api_client_secret'];
|
||||
var contentTypes = [];
|
||||
var accepts = ['application/json', 'application/xml'];
|
||||
var returnType = [Order];
|
||||
|
||||
return this.apiClient.callApi(
|
||||
'/store/findByStatus', 'GET',
|
||||
pathParams, queryParams, headerParams, formParams, postBody,
|
||||
authNames, contentTypes, accepts, returnType, callback
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
@ -113,7 +148,7 @@
|
||||
var formParams = {
|
||||
};
|
||||
|
||||
var authNames = ['test_api_key_query', 'test_api_key_header'];
|
||||
var authNames = ['test_api_key_header', 'test_api_key_query'];
|
||||
var contentTypes = [];
|
||||
var accepts = ['application/json', 'application/xml'];
|
||||
var returnType = Order;
|
||||
|
@ -1,23 +1,23 @@
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['./ApiClient', './model/Order', './model/User', './model/Category', './model/Tag', './model/Pet', './api/UserApi', './api/StoreApi', './api/PetApi'], factory);
|
||||
define(['./ApiClient', './model/User', './model/Category', './model/Pet', './model/Tag', './model/Order', './api/UserApi', './api/PetApi', './api/StoreApi'], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
// CommonJS-like environments that support module.exports, like Node.
|
||||
module.exports = factory(require('./ApiClient'), require('./model/Order'), require('./model/User'), require('./model/Category'), require('./model/Tag'), require('./model/Pet'), require('./api/UserApi'), require('./api/StoreApi'), require('./api/PetApi'));
|
||||
module.exports = factory(require('./ApiClient'), require('./model/User'), require('./model/Category'), require('./model/Pet'), require('./model/Tag'), require('./model/Order'), require('./api/UserApi'), require('./api/PetApi'), require('./api/StoreApi'));
|
||||
}
|
||||
}(function(ApiClient, Order, User, Category, Tag, Pet, UserApi, StoreApi, PetApi) {
|
||||
}(function(ApiClient, User, Category, Pet, Tag, Order, UserApi, PetApi, StoreApi) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
ApiClient: ApiClient,
|
||||
Order: Order,
|
||||
User: User,
|
||||
Category: Category,
|
||||
Tag: Tag,
|
||||
Pet: Pet,
|
||||
Tag: Tag,
|
||||
Order: Order,
|
||||
UserApi: UserApi,
|
||||
StoreApi: StoreApi,
|
||||
PetApi: PetApi
|
||||
PetApi: PetApi,
|
||||
StoreApi: StoreApi
|
||||
};
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user