mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-02 15:00:58 +00:00
Add tests for API
This commit is contained in:
parent
b9eb26baff
commit
42f669031d
@ -28,10 +28,11 @@ goog.require('{{import}}');
|
||||
{{/description}}
|
||||
* @constructor
|
||||
* @param {!angular.$http} $http
|
||||
* @param {!Object} $httpParamSerializer
|
||||
* @param {!angular.$injector} $injector
|
||||
* @struct
|
||||
*/
|
||||
{{package}}.{{classname}} = function($http, $injector) {
|
||||
{{package}}.{{classname}} = function($http, $httpParamSerializer, $injector) {
|
||||
/** @private {!string} */
|
||||
this.basePath_ = $injector.has('{{classname}}BasePath') ?
|
||||
/** @type {!string} */ ($injector.get('{{classname}}BasePath')) :
|
||||
@ -45,8 +46,11 @@ goog.require('{{import}}');
|
||||
|
||||
/** @private {!angular.$http} */
|
||||
this.http_ = $http;
|
||||
|
||||
/** @private {!Object} */
|
||||
this.httpParamSerializer_ = $injector.get('$httpParamSerializer');
|
||||
}
|
||||
{{package}}.{{classname}}.$inject = ['$http', '$injector'];
|
||||
{{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
||||
{{#operation}}
|
||||
|
||||
/**
|
||||
@ -57,87 +61,64 @@ goog.require('{{import}}');
|
||||
* @return {!angular.$q.Promise{{#returnType}}<!{{{returnType}}}>{{/returnType}}}
|
||||
*/
|
||||
{{package}}.{{classname}}.prototype.{{nickname}} = function({{#allParams}}{{^required}}opt_{{/required}}{{paramName}}, {{/allParams}}opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '{{path}}'{{#pathParams}}
|
||||
.replace('{' + '{{baseName}}' + '}', String({{^required}}opt_{{/required}}{{paramName}})){{/pathParams}};
|
||||
{{#required}}
|
||||
|
||||
// verify required parameter '{{paramName}}' is set
|
||||
if (!{{paramName}}) {
|
||||
throw new Error('Missing required parameter {{paramName}} when calling {{nickname}}');
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
{{#hasFormParams}}
|
||||
/** @type {!Object} */
|
||||
var formParams = {};
|
||||
|
||||
{{/hasFormParams}}
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify required parameter '{{^required}}opt_{{/required}}{{paramName}}' is set
|
||||
if (!{{^required}}opt_{{/required}}{{paramName}}) {
|
||||
throw new Error('Missing required parameter {{^required}}opt_{{/required}}{{paramName}} when calling {{nickname}}');
|
||||
}
|
||||
{{/required}}
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var queryParameters = {};
|
||||
{{/allParams}}
|
||||
{{#queryParams}}
|
||||
if ({{^required}}opt_{{/required}}{{paramName}} !== undefined) {
|
||||
queryParameters['{{baseName}}'] = String({{^required}}opt_{{/required}}{{paramName}});
|
||||
queryParameters['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
|
||||
}
|
||||
{{/queryParams}}
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}
|
||||
if ({{^required}}opt_{{/required}}{{paramName}} !== undefined) {
|
||||
headerParams['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
|
||||
}
|
||||
headerParams['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
|
||||
|
||||
{{/headerParams}}
|
||||
{{#hasFormParams}}
|
||||
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
/** @type {!FormData} */
|
||||
var formParams = new FormData();
|
||||
{{/hasFormParams}}
|
||||
{{#formParams}}
|
||||
if ({{^required}}opt_{{/required}}{{paramName}} !== undefined) {
|
||||
var {{paramName}}_ = /** @type {?} */ ({{^required}}opt_{{/required}}{{paramName}});
|
||||
if ({{paramName}}_ instanceof Blob) {
|
||||
formParams.append('{{baseName}}', {{paramName}}_);
|
||||
} else if (typeof {{paramName}}_ === 'string') {
|
||||
formParams.append('{{baseName}}', {{paramName}}_);
|
||||
} else {
|
||||
throw new Error('Forms parameter {{^required}}opt_{{/required}}{{paramName}} is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)');
|
||||
}
|
||||
}
|
||||
{{/formParams}}
|
||||
{{#allParams}}
|
||||
{{/allParams}}
|
||||
formParams['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},{{#bodyParam}}
|
||||
data: {{paramName}},{{/bodyParam}}{{#hasFormParams}}
|
||||
data: formParams,{{/hasFormParams}}
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
{{/formParams}}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: '{{httpMethod}}',
|
||||
url: path,
|
||||
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
|
||||
{{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}},
|
||||
{{/bodyParam}}
|
||||
{{#hasFormParams}}data: this.httpParamSerializer_(formParams),
|
||||
{{/hasFormParams}}
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('{{httpMethod}}') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
2
samples/client/petstore/javascript-closure-angular/.gitignore
vendored
Normal file
2
samples/client/petstore/javascript-closure-angular/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.compiled.js
|
||||
node_modules
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* 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
|
||||
* Version: 1.0.0
|
||||
* Generated at: 2016-01-27T23:51:03.092-07:00
|
||||
* Generated at: 2016-02-02T00:45:38.616-07:00
|
||||
* Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
*/
|
||||
/**
|
||||
@ -16,15 +16,15 @@
|
||||
goog.provide('API.Client.PetApi');
|
||||
|
||||
goog.require('API.Client.Pet');
|
||||
goog.require('API.Client.binary');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {!angular.$http} $http
|
||||
* @param {!Object} $httpParamSerializer
|
||||
* @param {!angular.$injector} $injector
|
||||
* @struct
|
||||
*/
|
||||
API.Client.PetApi = function($http, $injector) {
|
||||
API.Client.PetApi = function($http, $httpParamSerializer, $injector) {
|
||||
/** @private {!string} */
|
||||
this.basePath_ = $injector.has('PetApiBasePath') ?
|
||||
/** @type {!string} */ ($injector.get('PetApiBasePath')) :
|
||||
@ -38,8 +38,11 @@ API.Client.PetApi = function($http, $injector) {
|
||||
|
||||
/** @private {!angular.$http} */
|
||||
this.http_ = $http;
|
||||
|
||||
/** @private {!Object} */
|
||||
this.httpParamSerializer_ = $injector.get('$httpParamSerializer');
|
||||
}
|
||||
API.Client.PetApi.$inject = ['$http', '$injector'];
|
||||
API.Client.PetApi.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
@ -49,49 +52,31 @@ API.Client.PetApi.$inject = ['$http', '$injector'];
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.updatePet = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('PUT') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,49 +87,31 @@ API.Client.PetApi.prototype.updatePet = function(opt_body, opt_extraHttpRequestP
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.addPet = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,51 +122,34 @@ API.Client.PetApi.prototype.addPet = function(opt_body, opt_extraHttpRequestPara
|
||||
* @return {!angular.$q.Promise<!Array<!API.Client.Pet>>}
|
||||
*/
|
||||
API.Client.PetApi.prototype.findPetsByStatus = function(opt_status, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/findByStatus';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
if (opt_status !== undefined) {
|
||||
queryParameters['status'] = String(opt_status);
|
||||
queryParameters['status'] = opt_status;
|
||||
}
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,51 +160,34 @@ API.Client.PetApi.prototype.findPetsByStatus = function(opt_status, opt_extraHtt
|
||||
* @return {!angular.$q.Promise<!Array<!API.Client.Pet>>}
|
||||
*/
|
||||
API.Client.PetApi.prototype.findPetsByTags = function(opt_tags, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/findByTags';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
if (opt_tags !== undefined) {
|
||||
queryParameters['tags'] = String(opt_tags);
|
||||
queryParameters['tags'] = opt_tags;
|
||||
}
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,49 +198,35 @@ API.Client.PetApi.prototype.findPetsByTags = function(opt_tags, opt_extraHttpReq
|
||||
* @return {!angular.$q.Promise<!API.Client.Pet>}
|
||||
*/
|
||||
API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,73 +239,45 @@ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestPar
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_status, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var formParams = {};
|
||||
|
||||
/** @type {!FormData} */
|
||||
var formParams = new FormData();
|
||||
if (opt_name !== undefined) {
|
||||
var name_ = /** @type {?} */ (opt_name);
|
||||
if (name_ instanceof Blob) {
|
||||
formParams.append('name', name_);
|
||||
} else if (typeof name_ === 'string') {
|
||||
formParams.append('name', name_);
|
||||
} else {
|
||||
throw new Error('Forms parameter opt_name is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)');
|
||||
}
|
||||
}
|
||||
if (opt_status !== undefined) {
|
||||
var status_ = /** @type {?} */ (opt_status);
|
||||
if (status_ instanceof Blob) {
|
||||
formParams.append('status', status_);
|
||||
} else if (typeof status_ === 'string') {
|
||||
formParams.append('status', status_);
|
||||
} else {
|
||||
throw new Error('Forms parameter opt_status is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)');
|
||||
}
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling updatePetWithForm');
|
||||
}
|
||||
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: false,
|
||||
data: formParams,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
formParams['name'] = opt_name;
|
||||
|
||||
formParams['status'] = opt_status;
|
||||
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: false,
|
||||
|
||||
data: this.httpParamSerializer_(formParams),
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,52 +289,37 @@ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_st
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
if (opt_apiKey !== undefined) {
|
||||
headerParams['api_key'] = opt_apiKey;
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
headerParams['api_key'] = opt_apiKey;
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('DELETE') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -456,73 +332,45 @@ API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHtt
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, opt_file, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var formParams = {};
|
||||
|
||||
/** @type {!FormData} */
|
||||
var formParams = new FormData();
|
||||
if (opt_additionalMetadata !== undefined) {
|
||||
var additionalMetadata_ = /** @type {?} */ (opt_additionalMetadata);
|
||||
if (additionalMetadata_ instanceof Blob) {
|
||||
formParams.append('additionalMetadata', additionalMetadata_);
|
||||
} else if (typeof additionalMetadata_ === 'string') {
|
||||
formParams.append('additionalMetadata', additionalMetadata_);
|
||||
} else {
|
||||
throw new Error('Forms parameter opt_additionalMetadata is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)');
|
||||
}
|
||||
}
|
||||
if (opt_file !== undefined) {
|
||||
var file_ = /** @type {?} */ (opt_file);
|
||||
if (file_ instanceof Blob) {
|
||||
formParams.append('file', file_);
|
||||
} else if (typeof file_ === 'string') {
|
||||
formParams.append('file', file_);
|
||||
} else {
|
||||
throw new Error('Forms parameter opt_file is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)');
|
||||
}
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling uploadFile');
|
||||
}
|
||||
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: false,
|
||||
data: formParams,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
formParams['additionalMetadata'] = opt_additionalMetadata;
|
||||
|
||||
formParams['file'] = opt_file;
|
||||
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: false,
|
||||
|
||||
data: this.httpParamSerializer_(formParams),
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -530,103 +378,71 @@ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata,
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param {!number} petId ID of pet that needs to be fetched
|
||||
* @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
|
||||
* @return {!angular.$q.Promise<!API.Client.binary>}
|
||||
* @return {!angular.$q.Promise<!string>}
|
||||
*/
|
||||
API.Client.PetApi.prototype.getPetByIdWithByteArray = function(petId, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet/{petId}?testing_byte_array=true'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetByIdWithByteArray');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
*
|
||||
* @param {!API.Client.binary=} opt_body Pet object in the form of byte array
|
||||
* @param {!string=} opt_body Pet object in the form of byte array
|
||||
* @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.PetApi.prototype.addPetUsingByteArray = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/pet?testing_byte_array=true';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* 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
|
||||
* Version: 1.0.0
|
||||
* Generated at: 2016-01-27T23:51:03.092-07:00
|
||||
* Generated at: 2016-02-02T00:45:38.616-07:00
|
||||
* Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
*/
|
||||
/**
|
||||
@ -20,10 +20,11 @@ goog.require('API.Client.Order');
|
||||
/**
|
||||
* @constructor
|
||||
* @param {!angular.$http} $http
|
||||
* @param {!Object} $httpParamSerializer
|
||||
* @param {!angular.$injector} $injector
|
||||
* @struct
|
||||
*/
|
||||
API.Client.StoreApi = function($http, $injector) {
|
||||
API.Client.StoreApi = function($http, $httpParamSerializer, $injector) {
|
||||
/** @private {!string} */
|
||||
this.basePath_ = $injector.has('StoreApiBasePath') ?
|
||||
/** @type {!string} */ ($injector.get('StoreApiBasePath')) :
|
||||
@ -37,8 +38,11 @@ API.Client.StoreApi = function($http, $injector) {
|
||||
|
||||
/** @private {!angular.$http} */
|
||||
this.http_ = $http;
|
||||
|
||||
/** @private {!Object} */
|
||||
this.httpParamSerializer_ = $injector.get('$httpParamSerializer');
|
||||
}
|
||||
API.Client.StoreApi.$inject = ['$http', '$injector'];
|
||||
API.Client.StoreApi.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
@ -47,48 +51,30 @@ API.Client.StoreApi.$inject = ['$http', '$injector'];
|
||||
* @return {!angular.$q.Promise<!Object<!string, number>>}
|
||||
*/
|
||||
API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/store/inventory';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,49 +85,31 @@ API.Client.StoreApi.prototype.getInventory = function(opt_extraHttpRequestParams
|
||||
* @return {!angular.$q.Promise<!API.Client.Order>}
|
||||
*/
|
||||
API.Client.StoreApi.prototype.placeOrder = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/store/order';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,49 +120,35 @@ API.Client.StoreApi.prototype.placeOrder = function(opt_body, opt_extraHttpReque
|
||||
* @return {!angular.$q.Promise<!API.Client.Order>}
|
||||
*/
|
||||
API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling getOrderById');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,47 +159,33 @@ API.Client.StoreApi.prototype.getOrderById = function(orderId, opt_extraHttpRequ
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.StoreApi.prototype.deleteOrder = function(orderId, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling deleteOrder');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('DELETE') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* 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
|
||||
* Version: 1.0.0
|
||||
* Generated at: 2016-01-27T23:51:03.092-07:00
|
||||
* Generated at: 2016-02-02T00:45:38.616-07:00
|
||||
* Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
*/
|
||||
/**
|
||||
@ -20,10 +20,11 @@ goog.require('API.Client.User');
|
||||
/**
|
||||
* @constructor
|
||||
* @param {!angular.$http} $http
|
||||
* @param {!Object} $httpParamSerializer
|
||||
* @param {!angular.$injector} $injector
|
||||
* @struct
|
||||
*/
|
||||
API.Client.UserApi = function($http, $injector) {
|
||||
API.Client.UserApi = function($http, $httpParamSerializer, $injector) {
|
||||
/** @private {!string} */
|
||||
this.basePath_ = $injector.has('UserApiBasePath') ?
|
||||
/** @type {!string} */ ($injector.get('UserApiBasePath')) :
|
||||
@ -37,8 +38,11 @@ API.Client.UserApi = function($http, $injector) {
|
||||
|
||||
/** @private {!angular.$http} */
|
||||
this.http_ = $http;
|
||||
|
||||
/** @private {!Object} */
|
||||
this.httpParamSerializer_ = $injector.get('$httpParamSerializer');
|
||||
}
|
||||
API.Client.UserApi.$inject = ['$http', '$injector'];
|
||||
API.Client.UserApi.$inject = ['$http', '$httpParamSerializer', '$injector'];
|
||||
|
||||
/**
|
||||
* Create user
|
||||
@ -48,49 +52,31 @@ API.Client.UserApi.$inject = ['$http', '$injector'];
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.createUser = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,49 +87,31 @@ API.Client.UserApi.prototype.createUser = function(opt_body, opt_extraHttpReques
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.createUsersWithArrayInput = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/createWithArray';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,49 +122,31 @@ API.Client.UserApi.prototype.createUsersWithArrayInput = function(opt_body, opt_
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.createUsersWithListInput = function(opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/createWithList';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('POST') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,54 +158,38 @@ API.Client.UserApi.prototype.createUsersWithListInput = function(opt_body, opt_e
|
||||
* @return {!angular.$q.Promise<!string>}
|
||||
*/
|
||||
API.Client.UserApi.prototype.loginUser = function(opt_username, opt_password, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/login';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
if (opt_username !== undefined) {
|
||||
queryParameters['username'] = String(opt_username);
|
||||
queryParameters['username'] = opt_username;
|
||||
}
|
||||
|
||||
if (opt_password !== undefined) {
|
||||
queryParameters['password'] = String(opt_password);
|
||||
queryParameters['password'] = opt_password;
|
||||
}
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,48 +199,30 @@ API.Client.UserApi.prototype.loginUser = function(opt_username, opt_password, op
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/logout';
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -317,49 +233,35 @@ API.Client.UserApi.prototype.logoutUser = function(opt_extraHttpRequestParams) {
|
||||
* @return {!angular.$q.Promise<!API.Client.User>}
|
||||
*/
|
||||
API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling getUserByName');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('GET') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -371,50 +273,36 @@ API.Client.UserApi.prototype.getUserByName = function(username, opt_extraHttpReq
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.updateUser = function(username, opt_body, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling updateUser');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
json: true,
|
||||
data: opt_body,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('PUT') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,47 +313,33 @@ API.Client.UserApi.prototype.updateUser = function(username, opt_body, opt_extra
|
||||
* @return {!angular.$q.Promise}
|
||||
*/
|
||||
API.Client.UserApi.prototype.deleteUser = function(username, opt_extraHttpRequestParams) {
|
||||
/** @const {!string} */
|
||||
/** @const {string} */
|
||||
var path = this.basePath_ + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
/** @type {!Object} */
|
||||
var queryParameters = {};
|
||||
|
||||
/** @type {!Object<string,string>} */
|
||||
var headerParams = angular.copy(this.defaultHeaders_);
|
||||
|
||||
/** @type {!angular.$http.Config} */
|
||||
var httpRequestConfig = /** @type {!angular.$http.Config} */ ({
|
||||
url: path,
|
||||
json: true,
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
});
|
||||
/** @type {!Object} */
|
||||
var headerParams = angular.extend({}, this.defaultHeaders);
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling deleteUser');
|
||||
}
|
||||
/** @type {!Object} */
|
||||
var httpRequestParams = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
|
||||
params: queryParameters,
|
||||
headers: headerParams
|
||||
};
|
||||
|
||||
if (opt_extraHttpRequestParams) {
|
||||
// If an opt_extraHttpRequestParams object is passed in, override values
|
||||
// set the generated config with the passed in values.
|
||||
httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams);
|
||||
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
|
||||
}
|
||||
|
||||
// This whole block is to work around a limitation in closure compiler. It
|
||||
// would be better to call the $http service directly as a function, but that
|
||||
// isn't permitted since it has methods attached to it. Manually confirmed to
|
||||
// compile down to just a single method even with only SIMPLE optimization on.
|
||||
// https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393
|
||||
switch ('DELETE') {
|
||||
case 'GET':
|
||||
return this.http_.get(path, httpRequestConfig);
|
||||
case 'HEAD':
|
||||
return this.http_.head(path, httpRequestConfig);
|
||||
case 'POST':
|
||||
return this.http_.post(path, {}, httpRequestConfig);
|
||||
case 'PUT':
|
||||
return this.http_.put(path, {}, httpRequestConfig);
|
||||
case 'DELETE':
|
||||
return this.http_.delete(path, httpRequestConfig);
|
||||
case 'PATCH':
|
||||
return this.http_.patch(path, {}, httpRequestConfig);
|
||||
}
|
||||
return this.http_(httpRequestParams);
|
||||
}
|
||||
|
63
samples/client/petstore/javascript-closure-angular/compile.py
Executable file
63
samples/client/petstore/javascript-closure-angular/compile.py
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import httplib, urllib, sys
|
||||
|
||||
# Collect all the files in an order that will work. That is Models first then APIs
|
||||
def concatFiles(files):
|
||||
code = ""
|
||||
for file in files:
|
||||
code += open(file).read()
|
||||
return code
|
||||
|
||||
def makeRequest(params):
|
||||
# Always use the following value for the Content-type header.
|
||||
headers = { "Content-type": "application/x-www-form-urlencoded" }
|
||||
conn = httplib.HTTPConnection('closure-compiler.appspot.com')
|
||||
conn.request('POST', '/compile', params, headers)
|
||||
response = conn.getresponse()
|
||||
data = response.read()
|
||||
conn.close()
|
||||
return data
|
||||
|
||||
def checkForCompilerErrors(files):
|
||||
params = urllib.urlencode([
|
||||
('js_code', concatFiles(files)),
|
||||
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
|
||||
('language', 'ECMASCRIPT5_STRICT'),
|
||||
('output_format', 'text'),
|
||||
('output_info', 'errors'),
|
||||
])
|
||||
|
||||
return makeRequest(params)
|
||||
|
||||
def compile(output, files):
|
||||
params = urllib.urlencode([
|
||||
('js_code', concatFiles(files)),
|
||||
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
|
||||
('language', 'ECMASCRIPT5_STRICT'),
|
||||
('output_format', 'text'),
|
||||
('output_info', 'compiled_code'),
|
||||
])
|
||||
|
||||
f = open(output, 'w')
|
||||
f.write(makeRequest(params))
|
||||
f.close()
|
||||
|
||||
targets = {
|
||||
"PetAPI": ["API/Client/Tag.js", "API/Client/Category.js", "API/Client/Pet.js", "API/Client/PetApi.js"],
|
||||
"StoreAPI": ["API/Client/Order.js", "API/Client/StoreApi.js"],
|
||||
"UserAPI": ["API/Client/User.js", "API/Client/UserApi.js"],
|
||||
}
|
||||
|
||||
def main():
|
||||
for name, targetFiles in targets.iteritems():
|
||||
errors = checkForCompilerErrors(targetFiles)
|
||||
if errors:
|
||||
print "Compiler errors when building %s" % name
|
||||
print errors
|
||||
|
||||
for name, targetFiles in targets.iteritems():
|
||||
compile("%s.compiled.js" % name, targets[name])
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
@ -0,0 +1,78 @@
|
||||
// Karma configuration
|
||||
// Generated on Tue Feb 02 2016 00:09:34 GMT-0700 (MST)
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
|
||||
// base path, that will be used to resolve files and exclude
|
||||
basePath: '',
|
||||
|
||||
|
||||
// frameworks to use
|
||||
frameworks: ['jasmine', 'closure'],
|
||||
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'node_modules/angular/angular.js',
|
||||
'node_modules/angular-mocks/angular-mocks.js',
|
||||
{pattern: 'lib/**/*.js', included: true},
|
||||
{pattern: 'API/**/*.js', included: false},
|
||||
{pattern: 'test/**/*.js'},
|
||||
],
|
||||
|
||||
preprocessors: {
|
||||
// tests are preprocessed for dependencies (closure)
|
||||
'test/**/*.js': ['closure', 'closure-iit'],
|
||||
// source files are preprocessed for dependencies
|
||||
'API/**/*.js': ['closure'],
|
||||
// external deps
|
||||
'lib/goog/deps.js': ['closure-deps']
|
||||
},
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [],
|
||||
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
|
||||
reporters: ['dots'],
|
||||
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
||||
// Start these browsers, currently available:
|
||||
// - Chrome
|
||||
// - ChromeCanary
|
||||
// - Firefox
|
||||
// - Opera (has to be installed with `npm install karma-opera-launcher`)
|
||||
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
|
||||
// - PhantomJS
|
||||
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
|
||||
browsers: ['PhantomJS'],
|
||||
|
||||
|
||||
// If browser does not capture in given timeout [ms], kill it
|
||||
captureTimeout: 60000,
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, it capture browsers, run tests and exit
|
||||
singleRun: false
|
||||
});
|
||||
};
|
1548
samples/client/petstore/javascript-closure-angular/lib/goog/base.js
Normal file
1548
samples/client/petstore/javascript-closure-angular/lib/goog/base.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"angular": "^1.4.9",
|
||||
"angular-mocks": "^1.4.9",
|
||||
"karma": "~0.13",
|
||||
"karma-closure": "~0.1.1"
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
goog.require('API.Client.PetApi');
|
||||
|
||||
angular.module('PetApi', [])
|
||||
.service('petApi', API.Client.PetApi)
|
||||
.value('PetApiBasePath', 'https://example.com');
|
||||
|
||||
describe('API.Client.PetAPI', function() {
|
||||
beforeEach(module('ng', 'ngMock', 'PetApi'));
|
||||
|
||||
/** @type {!Object} */
|
||||
var $httpBackend;
|
||||
|
||||
/** @type {!API.Client.PetAPI} */
|
||||
var api;
|
||||
|
||||
/** @type {!API.Client.Category} */
|
||||
var sampleCategory = {
|
||||
id: 345,
|
||||
name: 'categoryname',
|
||||
};
|
||||
|
||||
/** @type {!API.Client.Pet} */
|
||||
var samplePet = {
|
||||
id: 123,
|
||||
category: sampleCategory,
|
||||
name: 'petname',
|
||||
photoUrls: [],
|
||||
tags: [sampleTag],
|
||||
status: API.Client.Pet.StatusEnum.available,
|
||||
};
|
||||
|
||||
/** @type {!API.Client.Tag} */
|
||||
var sampleTag = {
|
||||
id: 345,
|
||||
name: 'categoryname',
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
inject(function($injector) {
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
api = $injector.get('petApi');
|
||||
})
|
||||
});
|
||||
|
||||
it('should update pets', function() {
|
||||
$httpBackend.expectPUT('https://example.com/pet', samplePet)
|
||||
.respond(200, '');
|
||||
api.updatePet(samplePet);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should add a pet', function() {
|
||||
$httpBackend.expectPOST('https://example.com/pet', samplePet)
|
||||
.respond(200, '');
|
||||
api.addPet(samplePet);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should find pets by status', function() {
|
||||
$httpBackend.expectGET('https://example.com/pet/findByStatus?status=sold')
|
||||
.respond(200, '');
|
||||
api.findPetsByStatus(API.Client.Pet.StatusEnum.sold);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should find a pet by tag', function() {
|
||||
$httpBackend.expectGET('https://example.com/pet/findByTags?tags=%7B%22id%22:345,%22name%22:%22categoryname%22%7D')
|
||||
.respond(200, '');
|
||||
api.findPetsByTags(sampleTag);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should get pet by id', function() {
|
||||
$httpBackend.expectGET('https://example.com/pet/789')
|
||||
.respond(200, '');
|
||||
api.getPetById(789);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should update pet with form', function() {
|
||||
$httpBackend.expectPOST('https://example.com/pet/890', "name=newname&status=pending")
|
||||
.respond(200, '');
|
||||
api.updatePetWithForm(890, 'newname', API.Client.Pet.StatusEnum.pending);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should delete a pet', function() {
|
||||
$httpBackend.expectDELETE('https://example.com/pet/234')
|
||||
.respond(200, '');
|
||||
api.deletePet(234);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
});
|
@ -0,0 +1,68 @@
|
||||
goog.require('API.Client.StoreApi');
|
||||
|
||||
angular.module('StoreApi', [])
|
||||
.service('storeApi', API.Client.StoreApi)
|
||||
.value('StoreApiBasePath', 'https://example.com');
|
||||
|
||||
describe('API.Client.StoreApi', function() {
|
||||
beforeEach(module('ng', 'ngMock', 'StoreApi'));
|
||||
|
||||
/** @type {!Object} */
|
||||
var $httpBackend;
|
||||
|
||||
/** @type {!API.Client.PetAPI} */
|
||||
var api;
|
||||
|
||||
/** @type {!Date} */
|
||||
fixedDate = new Date();
|
||||
|
||||
/** @type {!API.Client.Order} */
|
||||
var sampleOrder = {
|
||||
id: 123,
|
||||
petId: 234,
|
||||
quantity: 1,
|
||||
shipDate: fixedDate,
|
||||
status: API.Client.Order.StatusEnum.placed,
|
||||
complete: false,
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
inject(function($injector) {
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
api = $injector.get('storeApi');
|
||||
})
|
||||
});
|
||||
|
||||
it('should get the inventory', function() {
|
||||
$httpBackend.expectGET('https://example.com/store/inventory')
|
||||
.respond(200, 'ok');
|
||||
api.getInventory();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should place an order', function() {
|
||||
$httpBackend.expectPOST('https://example.com/store/order', sampleOrder)
|
||||
.respond(200, 'ok');
|
||||
api.placeOrder(sampleOrder);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should get an order by id', function() {
|
||||
$httpBackend.expectGET('https://example.com/store/order/345')
|
||||
.respond(200, 'ok');
|
||||
api.getOrderById(345);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should delete an order', function() {
|
||||
$httpBackend.expectDELETE('https://example.com/store/order/456')
|
||||
.respond(200, 'ok');
|
||||
api.deleteOrder(456);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
});
|
@ -0,0 +1,81 @@
|
||||
goog.require('API.Client.UserApi');
|
||||
|
||||
angular.module('UserApi', [])
|
||||
.service('UserApi', API.Client.UserApi)
|
||||
.value('UserApiBasePath', 'https://example.com');
|
||||
|
||||
describe('API.Client.PetAPI', function() {
|
||||
beforeEach(module('ng', 'ngMock', 'UserApi'));
|
||||
|
||||
/** @type {!Object} */
|
||||
var $httpBackend;
|
||||
|
||||
/** @type {!API.Client.UserApi} */
|
||||
var api;
|
||||
|
||||
/** @type {!API.Client.User} */
|
||||
var sampleUser = {
|
||||
id: 123,
|
||||
username: 'username',
|
||||
firstName: 'first',
|
||||
lastName: 'last',
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
userStatus: 0,
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
inject(function($injector) {
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
api = $injector.get('UserApi');
|
||||
})
|
||||
});
|
||||
|
||||
it('should create a user', function() {
|
||||
$httpBackend.expectPOST('https://example.com/user', sampleUser)
|
||||
.respond(200, '');
|
||||
api.createUser(sampleUser);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should create an array of users', function() {
|
||||
$httpBackend.expectPOST('https://example.com/user/createWithArray', [sampleUser])
|
||||
.respond(200, '');
|
||||
api.createUsersWithArrayInput([sampleUser]);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should create a list of users', function() {
|
||||
$httpBackend.expectPOST('https://example.com/user/createWithList', [sampleUser])
|
||||
.respond(200, '');
|
||||
api.createUsersWithListInput([sampleUser]);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should login a user', function() {
|
||||
$httpBackend.expectGET('https://example.com/user/login?password=password&username=username')
|
||||
.respond(200, '');
|
||||
api.loginUser('username', 'password');
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should logout a user', function() {
|
||||
$httpBackend.expectGET('https://example.com/user/logout')
|
||||
.respond(200, '');
|
||||
api.logoutUser();
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should get a user by username', function() {
|
||||
$httpBackend.expectGET('https://example.com/user/username')
|
||||
.respond(200, '');
|
||||
api.getUserByName('username');
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user