This commit is contained in:
MaxToby
2021-01-08 23:35:08 +08:00
parent 9d54da3c67
commit ce24620329
101 changed files with 10965 additions and 27 deletions

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,7 @@
language: node_js
node_js:
- "6"
- "6.1"
- "5"
- "5.11"

View File

@ -0,0 +1,142 @@
# swagger-js-client
SwaggerJsClient - JavaScript client for swagger-js-client
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version:
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
### For [Node.js](https://nodejs.org/)
#### npm
To publish the library as a [npm](https://www.npmjs.com/),
please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages).
Then install it via:
```shell
npm install swagger-js-client --save
```
##### Local development
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
```shell
npm install
```
Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
```shell
npm link
```
Finally, switch to the directory you want to use your swagger-js-client from, and run:
```shell
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
```
You should now be able to `require('swagger-js-client')` in javascript files from the directory you ran the last
command above from.
#### git
#
If the library is hosted at a git repository, e.g.
https://github.com/GIT_USER_ID/GIT_REPO_ID
then install it via:
```shell
npm install GIT_USER_ID/GIT_REPO_ID --save
```
### For browser
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
the above steps with Node.js and installing browserify with `npm install -g browserify`,
perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually
use this library):
```shell
browserify main.js > bundle.js
```
Then include *bundle.js* in the HTML pages.
### Webpack Configuration
Using Webpack you may encounter the following error: "Module not found: Error:
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
the following section to your webpack config:
```javascript
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
```
## Getting Started
Please follow the [installation](#installation) instruction and execute the following JS code:
```javascript
var SwaggerJsClient = require('swagger-js-client');
var api = new SwaggerJsClient.GreetApi()
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.ping(callback);
```
## Documentation for API Endpoints
All URIs are relative to *http://localhost*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*SwaggerJsClient.GreetApi* | [**ping**](docs/GreetApi.md#ping) | **GET** /user/ping |
*SwaggerJsClient.UserApiApi* | [**getUserInfo**](docs/UserApiApi.md#getUserInfo) | **GET** /api/user/{id} | 获取用户信息
*SwaggerJsClient.UserApiApi* | [**login**](docs/UserApiApi.md#login) | **POST** /api/user/login | 登录
*SwaggerJsClient.UserApiApi* | [**register**](docs/UserApiApi.md#register) | **POST** /api/user/register | 注册
*SwaggerJsClient.UserApiApi* | [**searchUser**](docs/UserApiApi.md#searchUser) | **GET** /api/user/search | 用户搜索
## Documentation for Models
- [SwaggerJsClient.LoginReq](docs/LoginReq.md)
- [SwaggerJsClient.RegisterReq](docs/RegisterReq.md)
- [SwaggerJsClient.UserInfoReply](docs/UserInfoReply.md)
- [SwaggerJsClient.UserInfoReq](docs/UserInfoReq.md)
- [SwaggerJsClient.UserSearchReply](docs/UserSearchReply.md)
- [SwaggerJsClient.UserSearchReq](docs/UserSearchReq.md)
## Documentation for Authorization
### apiKey
- **Type**: API key
- **API key parameter name**: Authorization
- **Location**: HTTP header

View File

@ -0,0 +1,47 @@
# SwaggerJsClient.GreetApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**ping**](GreetApi.md#ping) | **GET** /user/ping |
<a name="ping"></a>
# **ping**
> Object ping()
### Example
```javascript
var SwaggerJsClient = require('swagger-js-client');
var apiInstance = new SwaggerJsClient.GreetApi();
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.ping(callback);
```
### Parameters
This endpoint does not need any parameter.
### Return type
**Object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -0,0 +1,9 @@
# SwaggerJsClient.LoginReq
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**username** | **String** | | [optional]
**password** | **String** | | [optional]

View File

@ -0,0 +1,10 @@
# SwaggerJsClient.RegisterReq
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**username** | **String** | | [optional]
**password** | **String** | | [optional]
**mobile** | **String** | | [optional]

View File

@ -0,0 +1,193 @@
# SwaggerJsClient.UserApiApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**getUserInfo**](UserApiApi.md#getUserInfo) | **GET** /api/user/{id} | 获取用户信息
[**login**](UserApiApi.md#login) | **POST** /api/user/login | 登录
[**register**](UserApiApi.md#register) | **POST** /api/user/register | 注册
[**searchUser**](UserApiApi.md#searchUser) | **GET** /api/user/search | 用户搜索
<a name="getUserInfo"></a>
# **getUserInfo**
> UserInfoReply getUserInfo(id, body)
获取用户信息
### Example
```javascript
var SwaggerJsClient = require('swagger-js-client');
var apiInstance = new SwaggerJsClient.UserApiApi();
var id = "id_example"; // String |
var body = new SwaggerJsClient.UserInfoReq(); // UserInfoReq |
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.getUserInfo(id, body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**id** | **String**| |
**body** | [**UserInfoReq**](UserInfoReq.md)| |
### Return type
[**UserInfoReply**](UserInfoReply.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
<a name="login"></a>
# **login**
> Object login(body)
登录
### Example
```javascript
var SwaggerJsClient = require('swagger-js-client');
var apiInstance = new SwaggerJsClient.UserApiApi();
var body = new SwaggerJsClient.LoginReq(); // LoginReq |
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.login(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**LoginReq**](LoginReq.md)| |
### Return type
**Object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
<a name="register"></a>
# **register**
> Object register(body)
注册
注册一个用户
### Example
```javascript
var SwaggerJsClient = require('swagger-js-client');
var apiInstance = new SwaggerJsClient.UserApiApi();
var body = new SwaggerJsClient.RegisterReq(); // RegisterReq |
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.register(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**RegisterReq**](RegisterReq.md)| |
### Return type
**Object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
<a name="searchUser"></a>
# **searchUser**
> UserSearchReply searchUser(body)
用户搜索
### Example
```javascript
var SwaggerJsClient = require('swagger-js-client');
var apiInstance = new SwaggerJsClient.UserApiApi();
var body = new SwaggerJsClient.UserSearchReq(); // UserSearchReq |
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.searchUser(body, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**UserSearchReq**](UserSearchReq.md)| |
### Return type
[**UserSearchReply**](UserSearchReply.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -0,0 +1,12 @@
# SwaggerJsClient.UserInfoReply
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | | [optional]
**age** | **Number** | | [optional]
**birthday** | **String** | | [optional]
**description** | **String** | | [optional]
**tag** | **[String]** | | [optional]

View File

@ -0,0 +1,8 @@
# SwaggerJsClient.UserInfoReq
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **String** | | [optional]

View File

@ -0,0 +1,8 @@
# SwaggerJsClient.UserSearchReply
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**keyWord** | [**[UserInfoReply]**](UserInfoReply.md) | | [optional]

View File

@ -0,0 +1,8 @@
# SwaggerJsClient.UserSearchReq
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**keyWord** | **String** | | [optional]

View File

@ -0,0 +1,52 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1 @@
--timeout 10000

View File

@ -0,0 +1,22 @@
{
"name": "swagger-js-client",
"version": "1.0.0",
"description": "ERROR_UNKNOWN",
"license": "Unlicense",
"main": "src/index.js",
"scripts": {
"test": "mocha --recursive"
},
"browser": {
"fs": false
},
"dependencies": {
"superagent": "3.7.0",
"querystring": "0.2.0"
},
"devDependencies": {
"mocha": "~2.3.4",
"sinon": "1.17.3",
"expect.js": "~0.3.1"
}
}

View File

@ -0,0 +1,600 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['superagent', 'querystring'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('superagent'), require('querystring'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.ApiClient = factory(root.superagent, root.querystring);
}
}(this, function(superagent, querystring) {
'use strict';
/**
* @module ApiClient
* @version 1.0.0
*/
/**
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
* application to use this class directly - the *Api and model classes provide the public API for the service. The
* contents of this file should be regarded as internal but are documented for completeness.
* @alias module:ApiClient
* @class
*/
var exports = function() {
/**
* The base URL against which to resolve every API call's (relative) path.
* @type {String}
* @default http://localhost
*/
this.basePath = 'http://localhost'.replace(/\/+$/, '');
/**
* The authentication methods to be included for all API calls.
* @type {Array.<String>}
*/
this.authentications = {
'apiKey': {type: 'apiKey', 'in': 'header', name: 'Authorization'}
};
/**
* The default HTTP headers to be included for all API calls.
* @type {Array.<String>}
* @default {}
*/
this.defaultHeaders = {};
/**
* The default HTTP timeout for all API calls.
* @type {Number}
* @default 60000
*/
this.timeout = 60000;
/**
* If set to false an additional timestamp parameter is added to all API GET calls to
* prevent browser caching
* @type {Boolean}
* @default true
*/
this.cache = true;
/**
* If set to true, the client will save the cookies from each server
* response, and return them in the next request.
* @default false
*/
this.enableCookies = false;
/*
* Used to save and return cookies in a node.js (non-browser) setting,
* if this.enableCookies is set to true.
*/
if (typeof window === 'undefined') {
this.agent = new superagent.agent();
}
/*
* Allow user to override superagent agent
*/
this.requestAgent = null;
};
/**
* Returns a string representation for an actual parameter.
* @param param The actual parameter.
* @returns {String} The string representation of <code>param</code>.
*/
exports.prototype.paramToString = function(param) {
if (param == undefined || param == null) {
return '';
}
if (param instanceof Date) {
return param.toISOString();
}
return param.toString();
};
/**
* Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
* NOTE: query parameters are not handled here.
* @param {String} path The path to append to the base URL.
* @param {Object} pathParams The parameter values to append.
* @returns {String} The encoded path with parameter values substituted.
*/
exports.prototype.buildUrl = function(path, pathParams) {
if (!path.match(/^\//)) {
path = '/' + path;
}
var url = this.basePath + path;
var _this = this;
url = url.replace(/\{([\w-]+)\}/g, function(fullMatch, key) {
var value;
if (pathParams.hasOwnProperty(key)) {
value = _this.paramToString(pathParams[key]);
} else {
value = fullMatch;
}
return encodeURIComponent(value);
});
return url;
};
/**
* Checks whether the given content type represents JSON.<br>
* JSON content type examples:<br>
* <ul>
* <li>application/json</li>
* <li>application/json; charset=UTF8</li>
* <li>APPLICATION/JSON</li>
* </ul>
* @param {String} contentType The MIME content type to check.
* @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
*/
exports.prototype.isJsonMime = function(contentType) {
return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
};
/**
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
* @param {Array.<String>} contentTypes
* @returns {String} The chosen content type, preferring JSON.
*/
exports.prototype.jsonPreferredMime = function(contentTypes) {
for (var i = 0; i < contentTypes.length; i++) {
if (this.isJsonMime(contentTypes[i])) {
return contentTypes[i];
}
}
return contentTypes[0];
};
/**
* Checks whether the given parameter value represents file-like content.
* @param param The parameter to check.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
*/
exports.prototype.isFileParam = function(param) {
// fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
if (typeof require === 'function') {
var fs;
try {
fs = require('fs');
} catch (err) {}
if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
return true;
}
}
// Buffer in Node.js
if (typeof Buffer === 'function' && param instanceof Buffer) {
return true;
}
// Blob in browser
if (typeof Blob === 'function' && param instanceof Blob) {
return true;
}
// File in browser (it seems File object is also instance of Blob, but keep this for safe)
if (typeof File === 'function' && param instanceof File) {
return true;
}
return false;
};
/**
* Normalizes parameter values:
* <ul>
* <li>remove nils</li>
* <li>keep files and arrays</li>
* <li>format to string with `paramToString` for other cases</li>
* </ul>
* @param {Object.<String, Object>} params The parameters as object properties.
* @returns {Object.<String, Object>} normalized parameters.
*/
exports.prototype.normalizeParams = function(params) {
var newParams = {};
for (var key in params) {
if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
var value = params[key];
if (this.isFileParam(value) || Array.isArray(value)) {
newParams[key] = value;
} else {
newParams[key] = this.paramToString(value);
}
}
}
return newParams;
};
/**
* Enumeration of collection format separator strategies.
* @enum {String}
* @readonly
*/
exports.CollectionFormatEnum = {
/**
* Comma-separated values. Value: <code>csv</code>
* @const
*/
CSV: ',',
/**
* Space-separated values. Value: <code>ssv</code>
* @const
*/
SSV: ' ',
/**
* Tab-separated values. Value: <code>tsv</code>
* @const
*/
TSV: '\t',
/**
* Pipe(|)-separated values. Value: <code>pipes</code>
* @const
*/
PIPES: '|',
/**
* Native array. Value: <code>multi</code>
* @const
*/
MULTI: 'multi'
};
/**
* Builds a string representation of an array-type actual parameter, according to the given collection format.
* @param {Array} param An array parameter.
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
*/
exports.prototype.buildCollectionParam = function buildCollectionParam(param, collectionFormat) {
if (param == null) {
return null;
}
switch (collectionFormat) {
case 'csv':
return param.map(this.paramToString).join(',');
case 'ssv':
return param.map(this.paramToString).join(' ');
case 'tsv':
return param.map(this.paramToString).join('\t');
case 'pipes':
return param.map(this.paramToString).join('|');
case 'multi':
// return the array directly as SuperAgent will handle it as expected
return param.map(this.paramToString);
default:
throw new Error('Unknown collection format: ' + collectionFormat);
}
};
/**
* Applies authentication headers to the request.
* @param {Object} request The request object created by a <code>superagent()</code> call.
* @param {Array.<String>} authNames An array of authentication method names.
*/
exports.prototype.applyAuthToRequest = function(request, authNames) {
var _this = this;
authNames.forEach(function(authName) {
var auth = _this.authentications[authName];
switch (auth.type) {
case 'basic':
if (auth.username || auth.password) {
request.auth(auth.username || '', auth.password || '');
}
break;
case 'apiKey':
if (auth.apiKey) {
var data = {};
if (auth.apiKeyPrefix) {
data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey;
} else {
data[auth.name] = auth.apiKey;
}
if (auth['in'] === 'header') {
request.set(data);
} else {
request.query(data);
}
}
break;
case 'oauth2':
if (auth.accessToken) {
request.set({'Authorization': 'Bearer ' + auth.accessToken});
}
break;
default:
throw new Error('Unknown authentication type: ' + auth.type);
}
});
};
/**
* Deserializes an HTTP response body into a value of the specified type.
* @param {Object} response A SuperAgent response object.
* @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
* all properties on <code>data<code> will be converted to this type.
* @returns A value of the specified type.
*/
exports.prototype.deserialize = function deserialize(response, returnType) {
if (response == null || returnType == null || response.status == 204) {
return null;
}
// Rely on SuperAgent for parsing response body.
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
var data = response.body;
if (data == null || (typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length)) {
// SuperAgent does not always produce a body; use the unparsed response as a fallback
data = response.text;
}
return exports.convertToType(data, returnType);
};
/**
* Callback function to receive the result of the operation.
* @callback module:ApiClient~callApiCallback
* @param {String} error Error message, if any.
* @param data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Invokes the REST service using the supplied settings and parameters.
* @param {String} path The base URL to invoke.
* @param {String} httpMethod The HTTP method to use.
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
* @param {Object.<String, Object>} queryParams A map of query parameters and their values.
* @param {Object.<String, Object>} collectionQueryParams A map of collection query parameters and their values.
* @param {Object.<String, Object>} headerParams A map of header parameters and their values.
* @param {Object.<String, Object>} formParams A map of form parameters and their values.
* @param {Object} bodyParam The value to pass as the request body.
* @param {Array.<String>} authNames An array of authentication type names.
* @param {Array.<String>} contentTypes An array of request MIME types.
* @param {Array.<String>} accepts An array of acceptable response MIME types.
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
* constructor for a complex type.
* @param {module:ApiClient~callApiCallback} callback The callback function.
* @returns {Object} The SuperAgent request object.
*/
exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
queryParams, collectionQueryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,
returnType, callback) {
var _this = this;
var url = this.buildUrl(path, pathParams);
var request = superagent(httpMethod, url);
// apply authentications
this.applyAuthToRequest(request, authNames);
// set collection query parameters
for (var key in collectionQueryParams) {
if (collectionQueryParams.hasOwnProperty(key)) {
var param = collectionQueryParams[key];
if (param.collectionFormat === 'csv') {
// SuperAgent normally percent-encodes all reserved characters in a query parameter. However,
// commas are used as delimiters for the 'csv' collectionFormat so they must not be encoded. We
// must therefore construct and encode 'csv' collection query parameters manually.
if (param.value != null) {
var value = param.value.map(this.paramToString).map(encodeURIComponent).join(',');
request.query(encodeURIComponent(key) + "=" + value);
}
} else {
// All other collection query parameters should be treated as ordinary query parameters.
queryParams[key] = this.buildCollectionParam(param.value, param.collectionFormat);
}
}
}
// set query parameters
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
queryParams['_'] = new Date().getTime();
}
request.query(this.normalizeParams(queryParams));
// set header parameters
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
// set requestAgent if it is set by user
if (this.requestAgent) {
request.agent(this.requestAgent);
}
// set request timeout
request.timeout(this.timeout);
var contentType = this.jsonPreferredMime(contentTypes);
if (contentType) {
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
if(contentType != 'multipart/form-data') {
request.type(contentType);
}
} else if (!request.header['Content-Type']) {
request.type('application/json');
}
if (contentType === 'application/x-www-form-urlencoded') {
request.send(querystring.stringify(this.normalizeParams(formParams)));
} else if (contentType == 'multipart/form-data') {
var _formParams = this.normalizeParams(formParams);
for (var key in _formParams) {
if (_formParams.hasOwnProperty(key)) {
if (this.isFileParam(_formParams[key])) {
// file field
request.attach(key, _formParams[key]);
} else {
request.field(key, _formParams[key]);
}
}
}
} else if (bodyParam) {
request.send(bodyParam);
}
var accept = this.jsonPreferredMime(accepts);
if (accept) {
request.accept(accept);
}
if (returnType === 'Blob') {
request.responseType('blob');
} else if (returnType === 'String') {
request.responseType('string');
}
// Attach previously saved cookies, if enabled
if (this.enableCookies){
if (typeof window === 'undefined') {
this.agent.attachCookies(request);
}
else {
request.withCredentials();
}
}
request.end(function(error, response) {
if (callback) {
var data = null;
if (!error) {
try {
data = _this.deserialize(response, returnType);
if (_this.enableCookies && typeof window === 'undefined'){
_this.agent.saveCookies(response);
}
} catch (err) {
error = err;
}
}
callback(error, data, response);
}
});
return request;
};
/**
* Parses a string representation of a date value.
* @param {String} str The date value as an ISO-8601 full-date or date-time string.
* @returns {Date} The parsed date object.
*/
exports.parseDate = function(str) {
// OpenAPI 2.0 & 3.0 specs state that:
// - date values are serialized as ISO-8601 full-date strings.
// - date-time values are serialized as ISO-8601 date-time strings, in which the timezone offset is mandatory.
return new Date(str);
};
/**
* Converts a value to the specified type.
* @param {(String|Object)} data The data to convert, as a string or object.
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
* all properties on <code>data<code> will be converted to this type.
* @returns An instance of the specified type or null or undefined if data is null or undefined.
*/
exports.convertToType = function(data, type) {
if (data === null || data === undefined)
return data
switch (type) {
case 'Boolean':
return Boolean(data);
case 'Integer':
return parseInt(data, 10);
case 'Number':
return parseFloat(data);
case 'String':
return String(data);
case 'Date':
return this.parseDate(String(data));
case 'Blob':
return data;
default:
if (type === Object) {
// generic object, return directly
return data;
} else if (typeof type === 'function') {
// for model type like: User
return type.constructFromObject(data);
} else if (Array.isArray(type)) {
// for array type like: ['String']
var itemType = type[0];
return data.map(function(item) {
return exports.convertToType(item, itemType);
});
} else if (typeof type === 'object') {
// for plain object type like: {'String': 'Integer'}
var keyType, valueType;
for (var k in type) {
if (type.hasOwnProperty(k)) {
keyType = k;
valueType = type[k];
break;
}
}
var result = {};
for (var k in data) {
if (data.hasOwnProperty(k)) {
var key = exports.convertToType(k, keyType);
var value = exports.convertToType(data[k], valueType);
result[key] = value;
}
}
return result;
} else {
// for unknown type, return the data directly
return data;
}
}
};
/**
* Constructs a new map or array model from REST data.
* @param data {Object|Array} The REST data.
* @param obj {Object|Array} The target object or array.
*/
exports.constructFromObject = function(data, obj, itemType) {
if (Array.isArray(data)) {
for (var i = 0; i < data.length; i++) {
if (data.hasOwnProperty(i))
obj[i] = exports.convertToType(data[i], itemType);
}
} else {
for (var k in data) {
if (data.hasOwnProperty(k))
obj[k] = exports.convertToType(data[k], itemType);
}
}
};
/**
* The default API client implementation.
* @type {module:ApiClient}
*/
exports.instance = new exports();
return exports;
}));

View File

@ -0,0 +1,91 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.GreetApi = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* Greet service.
* @module api/GreetApi
* @version 1.0.0
*/
/**
* Constructs a new GreetApi.
* @alias module:api/GreetApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
var exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the ping operation.
* @callback module:api/GreetApi~pingCallback
* @param {String} error Error message, if any.
* @param {Object} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* @param {module:api/GreetApi~pingCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Object}
*/
this.ping = function(callback) {
var postBody = null;
var pathParams = {
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = Object;
return this.apiClient.callApi(
'/user/ping', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
};
return exports;
}));

View File

@ -0,0 +1,244 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'model/LoginReq', 'model/RegisterReq', 'model/UserInfoReply', 'model/UserInfoReq', 'model/UserSearchReply', 'model/UserSearchReq'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('../model/LoginReq'), require('../model/RegisterReq'), require('../model/UserInfoReply'), require('../model/UserInfoReq'), require('../model/UserSearchReply'), require('../model/UserSearchReq'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.UserApiApi = factory(root.SwaggerJsClient.ApiClient, root.SwaggerJsClient.LoginReq, root.SwaggerJsClient.RegisterReq, root.SwaggerJsClient.UserInfoReply, root.SwaggerJsClient.UserInfoReq, root.SwaggerJsClient.UserSearchReply, root.SwaggerJsClient.UserSearchReq);
}
}(this, function(ApiClient, LoginReq, RegisterReq, UserInfoReply, UserInfoReq, UserSearchReply, UserSearchReq) {
'use strict';
/**
* UserApi service.
* @module api/UserApiApi
* @version 1.0.0
*/
/**
* Constructs a new UserApiApi.
* @alias module:api/UserApiApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
var exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the getUserInfo operation.
* @callback module:api/UserApiApi~getUserInfoCallback
* @param {String} error Error message, if any.
* @param {module:model/UserInfoReply} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* 获取用户信息
* @param {String} id
* @param {module:model/UserInfoReq} body
* @param {module:api/UserApiApi~getUserInfoCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/UserInfoReply}
*/
this.getUserInfo = function(id, body, callback) {
var postBody = body;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling getUserInfo");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling getUserInfo");
}
var pathParams = {
'id': id
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = UserInfoReply;
return this.apiClient.callApi(
'/api/user/{id}', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the login operation.
* @callback module:api/UserApiApi~loginCallback
* @param {String} error Error message, if any.
* @param {Object} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* 登录
* @param {module:model/LoginReq} body
* @param {module:api/UserApiApi~loginCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Object}
*/
this.login = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling login");
}
var pathParams = {
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = Object;
return this.apiClient.callApi(
'/api/user/login', 'POST',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the register operation.
* @callback module:api/UserApiApi~registerCallback
* @param {String} error Error message, if any.
* @param {Object} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* 注册
* 注册一个用户
* @param {module:model/RegisterReq} body
* @param {module:api/UserApiApi~registerCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Object}
*/
this.register = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling register");
}
var pathParams = {
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = Object;
return this.apiClient.callApi(
'/api/user/register', 'POST',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the searchUser operation.
* @callback module:api/UserApiApi~searchUserCallback
* @param {String} error Error message, if any.
* @param {module:model/UserSearchReply} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* 用户搜索
* @param {module:model/UserSearchReq} body
* @param {module:api/UserApiApi~searchUserCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/UserSearchReply}
*/
this.searchUser = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling searchUser");
}
var pathParams = {
};
var queryParams = {
};
var collectionQueryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = UserSearchReply;
return this.apiClient.callApi(
'/api/user/search', 'GET',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
};
return exports;
}));

View File

@ -0,0 +1,107 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'model/LoginReq', 'model/RegisterReq', 'model/UserInfoReply', 'model/UserInfoReq', 'model/UserSearchReply', 'model/UserSearchReq', 'api/GreetApi', 'api/UserApiApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('./ApiClient'), require('./model/LoginReq'), require('./model/RegisterReq'), require('./model/UserInfoReply'), require('./model/UserInfoReq'), require('./model/UserSearchReply'), require('./model/UserSearchReq'), require('./api/GreetApi'), require('./api/UserApiApi'));
}
}(function(ApiClient, LoginReq, RegisterReq, UserInfoReply, UserInfoReq, UserSearchReply, UserSearchReq, GreetApi, UserApiApi) {
'use strict';
/**
* ERROR_UNKNOWN.<br>
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
* <p>
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
* <pre>
* var SwaggerJsClient = require('index'); // See note below*.
* var xxxSvc = new SwaggerJsClient.XxxApi(); // Allocate the API class we're going to use.
* var yyyModel = new SwaggerJsClient.Yyy(); // Construct a model instance.
* yyyModel.someProperty = 'someValue';
* ...
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
* ...
* </pre>
* <em>*NOTE: For a top-level AMD script, use require(['index'], function(){...})
* and put the application logic within the callback function.</em>
* </p>
* <p>
* A non-AMD browser application (discouraged) might do something like this:
* <pre>
* var xxxSvc = new SwaggerJsClient.XxxApi(); // Allocate the API class we're going to use.
* var yyy = new SwaggerJsClient.Yyy(); // Construct a model instance.
* yyyModel.someProperty = 'someValue';
* ...
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
* ...
* </pre>
* </p>
* @module index
* @version 1.0.0
*/
var exports = {
/**
* The ApiClient constructor.
* @property {module:ApiClient}
*/
ApiClient: ApiClient,
/**
* The LoginReq model constructor.
* @property {module:model/LoginReq}
*/
LoginReq: LoginReq,
/**
* The RegisterReq model constructor.
* @property {module:model/RegisterReq}
*/
RegisterReq: RegisterReq,
/**
* The UserInfoReply model constructor.
* @property {module:model/UserInfoReply}
*/
UserInfoReply: UserInfoReply,
/**
* The UserInfoReq model constructor.
* @property {module:model/UserInfoReq}
*/
UserInfoReq: UserInfoReq,
/**
* The UserSearchReply model constructor.
* @property {module:model/UserSearchReply}
*/
UserSearchReply: UserSearchReply,
/**
* The UserSearchReq model constructor.
* @property {module:model/UserSearchReq}
*/
UserSearchReq: UserSearchReq,
/**
* The GreetApi service constructor.
* @property {module:api/GreetApi}
*/
GreetApi: GreetApi,
/**
* The UserApiApi service constructor.
* @property {module:api/UserApiApi}
*/
UserApiApi: UserApiApi
};
return exports;
}));

View File

@ -0,0 +1,78 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.LoginReq = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The LoginReq model module.
* @module model/LoginReq
* @version 1.0.0
*/
/**
* Constructs a new <code>LoginReq</code>.
* @alias module:model/LoginReq
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>LoginReq</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/LoginReq} obj Optional instance to populate.
* @return {module:model/LoginReq} The populated <code>LoginReq</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('username'))
obj.username = ApiClient.convertToType(data['username'], 'String');
if (data.hasOwnProperty('password'))
obj.password = ApiClient.convertToType(data['password'], 'String');
}
return obj;
}
/**
* @member {String} username
*/
exports.prototype.username = undefined;
/**
* @member {String} password
*/
exports.prototype.password = undefined;
return exports;
}));

View File

@ -0,0 +1,85 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.RegisterReq = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The RegisterReq model module.
* @module model/RegisterReq
* @version 1.0.0
*/
/**
* Constructs a new <code>RegisterReq</code>.
* @alias module:model/RegisterReq
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>RegisterReq</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/RegisterReq} obj Optional instance to populate.
* @return {module:model/RegisterReq} The populated <code>RegisterReq</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('username'))
obj.username = ApiClient.convertToType(data['username'], 'String');
if (data.hasOwnProperty('password'))
obj.password = ApiClient.convertToType(data['password'], 'String');
if (data.hasOwnProperty('mobile'))
obj.mobile = ApiClient.convertToType(data['mobile'], 'String');
}
return obj;
}
/**
* @member {String} username
*/
exports.prototype.username = undefined;
/**
* @member {String} password
*/
exports.prototype.password = undefined;
/**
* @member {String} mobile
*/
exports.prototype.mobile = undefined;
return exports;
}));

View File

@ -0,0 +1,99 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.UserInfoReply = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The UserInfoReply model module.
* @module model/UserInfoReply
* @version 1.0.0
*/
/**
* Constructs a new <code>UserInfoReply</code>.
* @alias module:model/UserInfoReply
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>UserInfoReply</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/UserInfoReply} obj Optional instance to populate.
* @return {module:model/UserInfoReply} The populated <code>UserInfoReply</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('name'))
obj.name = ApiClient.convertToType(data['name'], 'String');
if (data.hasOwnProperty('age'))
obj.age = ApiClient.convertToType(data['age'], 'Number');
if (data.hasOwnProperty('birthday'))
obj.birthday = ApiClient.convertToType(data['birthday'], 'String');
if (data.hasOwnProperty('description'))
obj.description = ApiClient.convertToType(data['description'], 'String');
if (data.hasOwnProperty('tag'))
obj.tag = ApiClient.convertToType(data['tag'], ['String']);
}
return obj;
}
/**
* @member {String} name
*/
exports.prototype.name = undefined;
/**
* @member {Number} age
*/
exports.prototype.age = undefined;
/**
* @member {String} birthday
*/
exports.prototype.birthday = undefined;
/**
* @member {String} description
*/
exports.prototype.description = undefined;
/**
* @member {Array.<String>} tag
*/
exports.prototype.tag = undefined;
return exports;
}));

View File

@ -0,0 +1,71 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.UserInfoReq = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The UserInfoReq model module.
* @module model/UserInfoReq
* @version 1.0.0
*/
/**
* Constructs a new <code>UserInfoReq</code>.
* @alias module:model/UserInfoReq
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>UserInfoReq</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/UserInfoReq} obj Optional instance to populate.
* @return {module:model/UserInfoReq} The populated <code>UserInfoReq</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('id'))
obj.id = ApiClient.convertToType(data['id'], 'String');
}
return obj;
}
/**
* @member {String} id
*/
exports.prototype.id = undefined;
return exports;
}));

View File

@ -0,0 +1,71 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'model/UserInfoReply'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./UserInfoReply'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.UserSearchReply = factory(root.SwaggerJsClient.ApiClient, root.SwaggerJsClient.UserInfoReply);
}
}(this, function(ApiClient, UserInfoReply) {
'use strict';
/**
* The UserSearchReply model module.
* @module model/UserSearchReply
* @version 1.0.0
*/
/**
* Constructs a new <code>UserSearchReply</code>.
* @alias module:model/UserSearchReply
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>UserSearchReply</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/UserSearchReply} obj Optional instance to populate.
* @return {module:model/UserSearchReply} The populated <code>UserSearchReply</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('KeyWord'))
obj.keyWord = ApiClient.convertToType(data['KeyWord'], [UserInfoReply]);
}
return obj;
}
/**
* @member {Array.<module:model/UserInfoReply>} keyWord
*/
exports.prototype.keyWord = undefined;
return exports;
}));

View File

@ -0,0 +1,71 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerJsClient) {
root.SwaggerJsClient = {};
}
root.SwaggerJsClient.UserSearchReq = factory(root.SwaggerJsClient.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
/**
* The UserSearchReq model module.
* @module model/UserSearchReq
* @version 1.0.0
*/
/**
* Constructs a new <code>UserSearchReq</code>.
* @alias module:model/UserSearchReq
* @class
*/
var exports = function() {
};
/**
* Constructs a <code>UserSearchReq</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/UserSearchReq} obj Optional instance to populate.
* @return {module:model/UserSearchReq} The populated <code>UserSearchReq</code> instance.
*/
exports.constructFromObject = function(data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('keyWord'))
obj.keyWord = ApiClient.convertToType(data['keyWord'], 'String');
}
return obj;
}
/**
* @member {String} keyWord
*/
exports.prototype.keyWord = undefined;
return exports;
}));

View File

@ -0,0 +1,62 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
beforeEach(function() {
instance = new SwaggerJsClient.GreetApi();
});
describe('(package)', function() {
describe('GreetApi', function() {
describe('ping', function() {
it('should call ping successfully', function(done) {
// TODO: uncomment ping call and complete the assertions
/*
instance.ping(function(error, data, response) {
if (error) {
done(error);
return;
}
// TODO: update response assertions
expect(data).to.be.a(Object);
// expect(data).to.be(null);
done();
});
*/
// TODO: uncomment and complete method invocation above, then delete this line and the next:
done();
});
});
});
});
}));

View File

@ -0,0 +1,181 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
beforeEach(function() {
instance = new SwaggerJsClient.UserApiApi();
});
describe('(package)', function() {
describe('UserApiApi', function() {
describe('getUserInfo', function() {
it('should call getUserInfo successfully', function(done) {
// TODO: uncomment, update parameter values for getUserInfo call and complete the assertions
/*
var id = "id_example";
var body = new SwaggerJsClient.UserInfoReq();
body.id = "";
instance.getUserInfo(id, body, function(error, data, response) {
if (error) {
done(error);
return;
}
// TODO: update response assertions
expect(data).to.be.a(SwaggerJsClient.UserInfoReply);
expect(data.name).to.be.a('string');
expect(data.name).to.be("");
expect(data.age).to.be.a('number');
expect(data.age).to.be(0);
expect(data.birthday).to.be.a('string');
expect(data.birthday).to.be("");
expect(data.description).to.be.a('string');
expect(data.description).to.be("");
{
let dataCtr = data.tag;
expect(dataCtr).to.be.an(Array);
expect(dataCtr).to.not.be.empty();
for (let p in dataCtr) {
let data = dataCtr[p];
expect(data).to.be.a('string');
expect(data).to.be("");
}
}
done();
});
*/
// TODO: uncomment and complete method invocation above, then delete this line and the next:
done();
});
});
describe('login', function() {
it('should call login successfully', function(done) {
// TODO: uncomment, update parameter values for login call and complete the assertions
/*
var body = new SwaggerJsClient.LoginReq();
body.username = "";
body.password = "";
instance.login(body, function(error, data, response) {
if (error) {
done(error);
return;
}
// TODO: update response assertions
expect(data).to.be.a(Object);
// expect(data).to.be(null);
done();
});
*/
// TODO: uncomment and complete method invocation above, then delete this line and the next:
done();
});
});
describe('register', function() {
it('should call register successfully', function(done) {
// TODO: uncomment, update parameter values for register call and complete the assertions
/*
var body = new SwaggerJsClient.RegisterReq();
body.username = "";
body.password = "";
body.mobile = "";
instance.register(body, function(error, data, response) {
if (error) {
done(error);
return;
}
// TODO: update response assertions
expect(data).to.be.a(Object);
// expect(data).to.be(null);
done();
});
*/
// TODO: uncomment and complete method invocation above, then delete this line and the next:
done();
});
});
describe('searchUser', function() {
it('should call searchUser successfully', function(done) {
// TODO: uncomment, update parameter values for searchUser call and complete the assertions
/*
var body = new SwaggerJsClient.UserSearchReq();
body.keyWord = "";
instance.searchUser(body, function(error, data, response) {
if (error) {
done(error);
return;
}
// TODO: update response assertions
expect(data).to.be.a(SwaggerJsClient.UserSearchReply);
{
let dataCtr = data.keyWord;
expect(dataCtr).to.be.an(Array);
expect(dataCtr).to.not.be.empty();
for (let p in dataCtr) {
let data = dataCtr[p];
expect(data).to.be.a(SwaggerJsClient.UserInfoReply);
expect(data.name).to.be.a('string');
expect(data.name).to.be("");
expect(data.age).to.be.a('number');
expect(data.age).to.be(0);
expect(data.birthday).to.be.a('string');
expect(data.birthday).to.be("");
expect(data.description).to.be.a('string');
expect(data.description).to.be("");
{
let dataCtr = data.tag;
expect(dataCtr).to.be.an(Array);
expect(dataCtr).to.not.be.empty();
for (let p in dataCtr) {
let data = dataCtr[p];
expect(data).to.be.a('string');
expect(data).to.be("");
}
}
}
}
done();
});
*/
// TODO: uncomment and complete method invocation above, then delete this line and the next:
done();
});
});
});
});
}));

View File

@ -0,0 +1,81 @@
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.assertEquals = factory();
}
}(this, function() {
'use strict';
var assertEquals = function(expected, actual, ptr) {
if (!ptr)
ptr = "";
if (actual === expected)
return;
if (expected instanceof Date || actual instanceof Date) {
expected = toISODateString(expected);
actual = toISODateString(actual);
if (actual !== expected)
fail(expected, actual, ptr, "date value incorrect;");
}
if (!expected || !actual || typeof expected != 'object' && typeof actual != 'object') {
if (typeof actual != typeof expected)
fail(typeof expected, typeof actual, ptr, "value type incorrect;");
if (actual != expected)
fail(expected, actual, ptr, "value incorrect;");
}
return checkObject(expected, actual, ptr);
}
function toISODateString(value) {
if (value instanceof Date) {
// JavaScript's ISO string contains a milliseconds component that must be stripped out.
value = value.toISOString().replace('.000', '');
}
return value;
}
function checkObject(expected, actual, ptr) {
if (undefOrNull(expected) || undefOrNull(actual))
fail(expected, actual, ptr, "missing value;");
if (typeof expected !== typeof actual)
fail(typeof expected, typeof actual, ptr, "wrong type;");
if (expected.prototype !== actual.prototype)
fail(expected.prototype, actual.prototype, ptr, "wrong prototype;");
try {
var expectedKeys = Object.keys(expected);
var actualKeys = Object.keys(actual);
} catch (e) {
fail(expectedKeys, actualKeys, ptr, "wrong keys;");
}
if (actualKeys.length != expectedKeys.length)
fail(expectedKeys.length, actualKeys.length, ptr, "key count incorrect;");
expectedKeys.sort();
actualKeys.sort();
for (var i = 0; i < expectedKeys.length; i++) {
if (actualKeys[i] != expectedKeys[i])
fail(expectedKeys, actualKeys, ptr, "wrong keys;");
}
for (i = 0; i < expectedKeys.length; i++) {
var key = expectedKeys[i];
assertEquals(expected[key], actual[key], ptr + '/' + key);
}
}
function undefOrNull(v) {
return v === undefined || v === null;
}
function fail(expected, actual, ptr, msg) {
var text = ptr + ' ' + msg + " expected: " + expected + ", actual: " + actual;
console.log(text);
throw new Error(text);
}
return assertEquals;
}));

View File

@ -0,0 +1,58 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('LoginReq', function() {
beforeEach(function() {
instance = new SwaggerJsClient.LoginReq();
});
it('should create an instance of LoginReq', function() {
// TODO: update the code to test LoginReq
expect(instance).to.be.a(SwaggerJsClient.LoginReq);
});
it('should have the property username (base name: "username")', function() {
// TODO: update the code to test the property username
expect(instance).to.have.property('username');
// expect(instance.username).to.be(expectedValueLiteral);
});
it('should have the property password (base name: "password")', function() {
// TODO: update the code to test the property password
expect(instance).to.have.property('password');
// expect(instance.password).to.be(expectedValueLiteral);
});
});
});
}));

View File

@ -0,0 +1,64 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('RegisterReq', function() {
beforeEach(function() {
instance = new SwaggerJsClient.RegisterReq();
});
it('should create an instance of RegisterReq', function() {
// TODO: update the code to test RegisterReq
expect(instance).to.be.a(SwaggerJsClient.RegisterReq);
});
it('should have the property username (base name: "username")', function() {
// TODO: update the code to test the property username
expect(instance).to.have.property('username');
// expect(instance.username).to.be(expectedValueLiteral);
});
it('should have the property password (base name: "password")', function() {
// TODO: update the code to test the property password
expect(instance).to.have.property('password');
// expect(instance.password).to.be(expectedValueLiteral);
});
it('should have the property mobile (base name: "mobile")', function() {
// TODO: update the code to test the property mobile
expect(instance).to.have.property('mobile');
// expect(instance.mobile).to.be(expectedValueLiteral);
});
});
});
}));

View File

@ -0,0 +1,76 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('UserInfoReply', function() {
beforeEach(function() {
instance = new SwaggerJsClient.UserInfoReply();
});
it('should create an instance of UserInfoReply', function() {
// TODO: update the code to test UserInfoReply
expect(instance).to.be.a(SwaggerJsClient.UserInfoReply);
});
it('should have the property name (base name: "name")', function() {
// TODO: update the code to test the property name
expect(instance).to.have.property('name');
// expect(instance.name).to.be(expectedValueLiteral);
});
it('should have the property age (base name: "age")', function() {
// TODO: update the code to test the property age
expect(instance).to.have.property('age');
// expect(instance.age).to.be(expectedValueLiteral);
});
it('should have the property birthday (base name: "birthday")', function() {
// TODO: update the code to test the property birthday
expect(instance).to.have.property('birthday');
// expect(instance.birthday).to.be(expectedValueLiteral);
});
it('should have the property description (base name: "description")', function() {
// TODO: update the code to test the property description
expect(instance).to.have.property('description');
// expect(instance.description).to.be(expectedValueLiteral);
});
it('should have the property tag (base name: "tag")', function() {
// TODO: update the code to test the property tag
expect(instance).to.have.property('tag');
// expect(instance.tag).to.be(expectedValueLiteral);
});
});
});
}));

View File

@ -0,0 +1,52 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('UserInfoReq', function() {
beforeEach(function() {
instance = new SwaggerJsClient.UserInfoReq();
});
it('should create an instance of UserInfoReq', function() {
// TODO: update the code to test UserInfoReq
expect(instance).to.be.a(SwaggerJsClient.UserInfoReq);
});
it('should have the property id (base name: "id")', function() {
// TODO: update the code to test the property id
expect(instance).to.have.property('id');
// expect(instance.id).to.be(expectedValueLiteral);
});
});
});
}));

View File

@ -0,0 +1,52 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('UserSearchReply', function() {
beforeEach(function() {
instance = new SwaggerJsClient.UserSearchReply();
});
it('should create an instance of UserSearchReply', function() {
// TODO: update the code to test UserSearchReply
expect(instance).to.be.a(SwaggerJsClient.UserSearchReply);
});
it('should have the property keyWord (base name: "KeyWord")', function() {
// TODO: update the code to test the property keyWord
expect(instance).to.have.property('keyWord');
// expect(instance.keyWord).to.be(expectedValueLiteral);
});
});
});
}));

View File

@ -0,0 +1,52 @@
/*
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* OpenAPI spec version:
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.18
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['expect.js', '../../src/index'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
factory(require('expect.js'), require('../../src/index'));
} else {
// Browser globals (root is window)
factory(root.expect, root.SwaggerJsClient);
}
}(this, function(expect, SwaggerJsClient) {
'use strict';
var instance;
describe('(package)', function() {
describe('UserSearchReq', function() {
beforeEach(function() {
instance = new SwaggerJsClient.UserSearchReq();
});
it('should create an instance of UserSearchReq', function() {
// TODO: update the code to test UserSearchReq
expect(instance).to.be.a(SwaggerJsClient.UserSearchReq);
});
it('should have the property keyWord (base name: "keyWord")', function() {
// TODO: update the code to test the property keyWord
expect(instance).to.have.property('keyWord');
// expect(instance.keyWord).to.be(expectedValueLiteral);
});
});
});
}));