forked from loafle/openapi-generator-original
update all petstore security samples
This commit is contained in:
parent
c4d5ba1533
commit
c783ec1d41
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/silex -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l silex-PHP -o samples/server/petstore-security-test/silex"
|
ags="$@ generate -t modules/swagger-codegen/src/main/resources/php-silex -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l php-silex -o samples/server/petstore-security-test/silex"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -26,6 +26,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/typescript-angular2 -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-angular -o samples/client/petstore-security-test/typescript-angular2"
|
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l typescript-angular -o samples/client/petstore-security-test/typescript-angular2"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -139,14 +139,7 @@ namespace IO.Swagger.Client
|
|||||||
|
|
||||||
if (postBody != null) // http body (model or byte[]) parameter
|
if (postBody != null) // http body (model or byte[]) parameter
|
||||||
{
|
{
|
||||||
if (postBody.GetType() == typeof(String))
|
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
||||||
{
|
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
|
||||||
}
|
|
||||||
else if (postBody.GetType() == typeof(byte[]))
|
|
||||||
{
|
|
||||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
@ -351,9 +344,25 @@ namespace IO.Swagger.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///Check if the given MIME is a JSON MIME.
|
||||||
|
///JSON MIME examples:
|
||||||
|
/// application/json
|
||||||
|
/// application/json; charset=UTF8
|
||||||
|
/// APPLICATION/JSON
|
||||||
|
/// application/vnd.company+json
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mime">MIME</param>
|
||||||
|
/// <returns>Returns True if MIME type is json.</returns>
|
||||||
|
public bool IsJsonMime(String mime)
|
||||||
|
{
|
||||||
|
var jsonRegex = new Regex("(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$");
|
||||||
|
return mime != null && (jsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select the Content-Type header's value from the given content-type array:
|
/// Select the Content-Type header's value from the given content-type array:
|
||||||
/// if JSON exists in the given array, use it;
|
/// if JSON type exists in the given array, use it;
|
||||||
/// otherwise use the first one defined in 'consumes'
|
/// otherwise use the first one defined in 'consumes'
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="contentTypes">The Content-Type array to select from.</param>
|
/// <param name="contentTypes">The Content-Type array to select from.</param>
|
||||||
@ -361,11 +370,14 @@ namespace IO.Swagger.Client
|
|||||||
public String SelectHeaderContentType(String[] contentTypes)
|
public String SelectHeaderContentType(String[] contentTypes)
|
||||||
{
|
{
|
||||||
if (contentTypes.Length == 0)
|
if (contentTypes.Length == 0)
|
||||||
return null;
|
|
||||||
|
|
||||||
if (contentTypes.Contains("application/json", StringComparer.OrdinalIgnoreCase))
|
|
||||||
return "application/json";
|
return "application/json";
|
||||||
|
|
||||||
|
foreach (var contentType in contentTypes)
|
||||||
|
{
|
||||||
|
if (IsJsonMime(contentType.ToLower()))
|
||||||
|
return contentType;
|
||||||
|
}
|
||||||
|
|
||||||
return contentTypes[0]; // use the first content type specified in 'consumes'
|
return contentTypes[0]; // use the first content type specified in 'consumes'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
@ -77,14 +77,14 @@ func (a *FakeApiService) TestCodeInjectEndRnNR(localVarOptionals map[string]inte
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
localVarHttpResponse, err := a.client.callAPI(r)
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||||||
if err != nil || localVarHttpResponse == nil {
|
if err != nil || localVarHttpResponse == nil {
|
||||||
return localVarHttpResponse, err
|
return localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
defer localVarHttpResponse.Body.Close()
|
defer localVarHttpResponse.Body.Close()
|
||||||
if localVarHttpResponse.StatusCode >= 300 {
|
if localVarHttpResponse.StatusCode >= 300 {
|
||||||
return localVarHttpResponse, reportError(localVarHttpResponse.Status)
|
return localVarHttpResponse, reportError(localVarHttpResponse.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
return localVarHttpResponse, err
|
return localVarHttpResponse, err
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*
|
*
|
||||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package swagger
|
package swagger
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Generated by: io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
* Generated by: io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @license Apache 2.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
* @license Apache-2.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0.html *_/ ' \" =end -- \\r\\n \\n \\r
|
* http://www.apache.org/licenses/LICENSE-2.0.html *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2.2.3-SNAPSHOT
|
2.3.0-SNAPSHOT
|
@ -23,6 +23,30 @@ Then install it via:
|
|||||||
npm install swagger_petstore____end____rn_n_r --save
|
npm install swagger_petstore____end____rn_n_r --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_petstore____end____rn_n_r from, and run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
|
||||||
|
```
|
||||||
|
|
||||||
|
You should now be able to `require('swagger_petstore____end____rn_n_r')` in javascript files from the directory you ran the last
|
||||||
|
command above from.
|
||||||
|
|
||||||
#### git
|
#### git
|
||||||
#
|
#
|
||||||
If the library is hosted at a git repository, e.g.
|
If the library is hosted at a git repository, e.g.
|
||||||
@ -37,7 +61,8 @@ then install it via:
|
|||||||
|
|
||||||
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
|
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`,
|
the above steps with Node.js and installing browserify with `npm install -g browserify`,
|
||||||
perform the following (assuming *main.js* is your entry file):
|
perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually
|
||||||
|
use this library):
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
browserify main.js > bundle.js
|
browserify main.js > bundle.js
|
||||||
@ -45,6 +70,24 @@ browserify main.js > bundle.js
|
|||||||
|
|
||||||
Then include *bundle.js* in the HTML pages.
|
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
|
## Getting Started
|
||||||
|
|
||||||
Please follow the [installation](#installation) instruction and execute the following JS code:
|
Please follow the [installation](#installation) instruction and execute the following JS code:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "swagger_petstore____end____rn_n_r",
|
"name": "swagger_petstore____end____rn_n_r",
|
||||||
"version": "1.0.0 *_/ =end -- \r\n \n \r",
|
"version": "1.0.0 *_/ =end -- \r\n \n \r",
|
||||||
"description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters_______end______",
|
"description": "This_spec_is_mainly_for_testing_Petstore_server_and_contains_fake_endpoints_models__Please_do_not_use_this_for_any_other_purpose__Special_characters_______end______",
|
||||||
"license": "Unlicense",
|
"license": "Apache-2.0 */ ' " =end -- \r\n \n \r",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./node_modules/mocha/bin/mocha --recursive"
|
"test": "./node_modules/mocha/bin/mocha --recursive"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Swagger Codegen version: 2.2.3-SNAPSHOT
|
* Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
*
|
*
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*
|
*
|
||||||
@ -362,6 +362,7 @@
|
|||||||
* @param {String} httpMethod The HTTP method to use.
|
* @param {String} httpMethod The HTTP method to use.
|
||||||
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
|
* @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>} 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>} headerParams A map of header parameters and their values.
|
||||||
* @param {Object.<String, Object>} formParams A map of form 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 {Object} bodyParam The value to pass as the request body.
|
||||||
@ -374,7 +375,7 @@
|
|||||||
* @returns {Object} The SuperAgent request object.
|
* @returns {Object} The SuperAgent request object.
|
||||||
*/
|
*/
|
||||||
exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
|
exports.prototype.callApi = function callApi(path, httpMethod, pathParams,
|
||||||
queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,
|
queryParams, collectionQueryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts,
|
||||||
returnType, callback) {
|
returnType, callback) {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
@ -384,6 +385,25 @@
|
|||||||
// apply authentications
|
// apply authentications
|
||||||
this.applyAuthToRequest(request, authNames);
|
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
|
// set query parameters
|
||||||
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
||||||
queryParams['_'] = new Date().getTime();
|
queryParams['_'] = new Date().getTime();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Swagger Codegen version: 2.2.3-SNAPSHOT
|
* Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
*
|
*
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*
|
*
|
||||||
@ -71,6 +71,8 @@
|
|||||||
};
|
};
|
||||||
var queryParams = {
|
var queryParams = {
|
||||||
};
|
};
|
||||||
|
var collectionQueryParams = {
|
||||||
|
};
|
||||||
var headerParams = {
|
var headerParams = {
|
||||||
};
|
};
|
||||||
var formParams = {
|
var formParams = {
|
||||||
@ -84,7 +86,7 @@
|
|||||||
|
|
||||||
return this.apiClient.callApi(
|
return this.apiClient.callApi(
|
||||||
'/fake', 'PUT',
|
'/fake', 'PUT',
|
||||||
pathParams, queryParams, headerParams, formParams, postBody,
|
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
|
||||||
authNames, contentTypes, accepts, returnType, callback
|
authNames, contentTypes, accepts, returnType, callback
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Swagger Codegen version: 2.2.3-SNAPSHOT
|
* Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
*
|
*
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*
|
*
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
*
|
*
|
||||||
* Swagger Codegen version: 2.2.3-SNAPSHOT
|
* Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
*
|
*
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*
|
*
|
||||||
|
@ -251,10 +251,10 @@ use WWW::SwaggerClient::;
|
|||||||
my $api_instance = WWW::SwaggerClient::->new(
|
my $api_instance = WWW::SwaggerClient::->new(
|
||||||
);
|
);
|
||||||
|
|
||||||
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
my $test_code_inject_*/_'_"_=end____\r\n_\n_\r = 'test_code_inject_*/_'_"_=end____\r\n_\n_\r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
|
$api_instance->test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||||
|
@ -251,10 +251,10 @@ use Something::Deep::;
|
|||||||
my $api_instance = Something::Deep::->new(
|
my $api_instance = Something::Deep::->new(
|
||||||
);
|
);
|
||||||
|
|
||||||
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
my $test_code_inject_*/_'_"_=end____\r\n_\n_\r = 'test_code_inject_*/_'_"_=end____\r\n_\n_\r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
|
$api_instance->test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||||
|
@ -13,7 +13,7 @@ Method | HTTP request | Description
|
|||||||
|
|
||||||
|
|
||||||
# **test_code_inject____end__rn_n_r**
|
# **test_code_inject____end__rn_n_r**
|
||||||
> test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r)
|
> test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r)
|
||||||
|
|
||||||
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ use Something::Deep::FakeApi;
|
|||||||
my $api_instance = Something::Deep::FakeApi->new(
|
my $api_instance = Something::Deep::FakeApi->new(
|
||||||
);
|
);
|
||||||
|
|
||||||
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
my $test_code_inject_*/_'_"_=end____\r\n_\n_\r = 'test_code_inject_*/_'_"_=end____\r\n_\n_\r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
|
$api_instance->test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||||
@ -38,7 +38,7 @@ if ($@) {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**test code inject */ ' " =end __ \r\n \n \r** | **string**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
**test_code_inject_*/_'_"_=end____\r\n_\n_\r** | **string**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ sub new {
|
|||||||
#
|
#
|
||||||
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
#
|
#
|
||||||
# @param string $test code inject */ ' " =end __ \r\n \n \r To test code injection */ ' \" =_end -- \\r\\n \\n \\r (optional)
|
# @param string $test_code_inject_*/_'_"_=end____\r\n_\n_\r To test code injection */ ' \" =_end -- \\r\\n \\n \\r (optional)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'test code inject */ ' " =end __ \r\n \n \r' => {
|
'test_code_inject_*/_'_"_=end____\r\n_\n_\r' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
||||||
required => '0',
|
required => '0',
|
||||||
@ -89,8 +89,8 @@ sub test_code_inject____end__rn_n_r {
|
|||||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ \" =_end -- ');
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ \" =_end -- ');
|
||||||
|
|
||||||
# form params
|
# form params
|
||||||
if ( exists $args{'test code inject */ ' " =end __ \r\n \n \r'} ) {
|
if ( exists $args{'test_code_inject_*/_'_"_=end____\r\n_\n_\r'} ) {
|
||||||
$form_params->{'test code inject */ ' " =end -- \r\n \n \r'} = $self->{api_client}->to_form_value($args{'test code inject */ ' " =end __ \r\n \n \r'});
|
$form_params->{'test code inject */ ' " =end -- \r\n \n \r'} = $self->{api_client}->to_form_value($args{'test_code_inject_*/_'_"_=end____\r\n_\n_\r'});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
@ -13,7 +13,7 @@ Method | HTTP request | Description
|
|||||||
|
|
||||||
|
|
||||||
# **test_code_inject____end__rn_n_r**
|
# **test_code_inject____end__rn_n_r**
|
||||||
> test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r)
|
> test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r)
|
||||||
|
|
||||||
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ use WWW::SwaggerClient::FakeApi;
|
|||||||
my $api_instance = WWW::SwaggerClient::FakeApi->new(
|
my $api_instance = WWW::SwaggerClient::FakeApi->new(
|
||||||
);
|
);
|
||||||
|
|
||||||
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
my $test_code_inject_*/_'_"_=end____\r\n_\n_\r = 'test_code_inject_*/_'_"_=end____\r\n_\n_\r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
|
$api_instance->test_code_inject____end__rn_n_r(test_code_inject_*/_'_"_=end____\r\n_\n_\r => $test_code_inject_*/_'_"_=end____\r\n_\n_\r);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||||
@ -38,7 +38,7 @@ if ($@) {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**test code inject */ ' " =end __ \r\n \n \r** | **string**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
**test_code_inject_*/_'_"_=end____\r\n_\n_\r** | **string**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ sub new {
|
|||||||
#
|
#
|
||||||
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
#
|
#
|
||||||
# @param string $test code inject */ ' " =end __ \r\n \n \r To test code injection */ ' \" =_end -- \\r\\n \\n \\r (optional)
|
# @param string $test_code_inject_*/_'_"_=end____\r\n_\n_\r To test code injection */ ' \" =_end -- \\r\\n \\n \\r (optional)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'test code inject */ ' " =end __ \r\n \n \r' => {
|
'test_code_inject_*/_'_"_=end____\r\n_\n_\r' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
||||||
required => '0',
|
required => '0',
|
||||||
@ -89,8 +89,8 @@ sub test_code_inject____end__rn_n_r {
|
|||||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ \" =_end -- ');
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ \" =_end -- ');
|
||||||
|
|
||||||
# form params
|
# form params
|
||||||
if ( exists $args{'test code inject */ ' " =end __ \r\n \n \r'} ) {
|
if ( exists $args{'test_code_inject_*/_'_"_=end____\r\n_\n_\r'} ) {
|
||||||
$form_params->{'test code inject */ ' " =end -- \r\n \n \r'} = $self->{api_client}->to_form_value($args{'test code inject */ ' " =end __ \r\n \n \r'});
|
$form_params->{'test code inject */ ' " =end -- \r\n \n \r'} = $self->{api_client}->to_form_value($args{'test_code_inject_*/_'_"_=end____\r\n_\n_\r'});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
@ -283,7 +283,7 @@ class ApiClient(object):
|
|||||||
_request_timeout=None):
|
_request_timeout=None):
|
||||||
"""
|
"""
|
||||||
Makes the HTTP request (synchronous) and return the deserialized data.
|
Makes the HTTP request (synchronous) and return the deserialized data.
|
||||||
To make an async request, define a function for callback.
|
To make an async request, set the async parameter.
|
||||||
|
|
||||||
:param resource_path: Path to method endpoint.
|
:param resource_path: Path to method endpoint.
|
||||||
:param method: Method to call.
|
:param method: Method to call.
|
||||||
@ -307,10 +307,10 @@ class ApiClient(object):
|
|||||||
:param _request_timeout: timeout setting for this request. If one number provided, it will be total request
|
:param _request_timeout: timeout setting for this request. If one number provided, it will be total request
|
||||||
timeout. It can also be a pair (tuple) of (connection, read) timeouts.
|
timeout. It can also be a pair (tuple) of (connection, read) timeouts.
|
||||||
:return:
|
:return:
|
||||||
If provide parameter callback,
|
If async parameter is True,
|
||||||
the request will be called asynchronously.
|
the request will be called asynchronously.
|
||||||
The method will return the request thread.
|
The method will return the request thread.
|
||||||
If parameter callback is None,
|
If parameter async is False or missing,
|
||||||
then the method will return the response directly.
|
then the method will return the response directly.
|
||||||
"""
|
"""
|
||||||
if not async:
|
if not async:
|
||||||
|
@ -15,14 +15,30 @@ from __future__ import absolute_import
|
|||||||
|
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
import sys
|
import copy
|
||||||
import logging
|
import logging
|
||||||
|
import multiprocessing
|
||||||
|
import sys
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
from six import with_metaclass
|
||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
|
class TypeWithDefault(type):
|
||||||
|
def __init__(cls, name, bases, dct):
|
||||||
|
super(TypeWithDefault, cls).__init__(name, bases, dct)
|
||||||
|
cls._default = None
|
||||||
|
|
||||||
class Configuration(object):
|
def __call__(cls):
|
||||||
|
if cls._default == None:
|
||||||
|
cls._default = type.__call__(cls)
|
||||||
|
return copy.copy(cls._default)
|
||||||
|
|
||||||
|
def set_default(cls, default):
|
||||||
|
cls._default = copy.copy(default)
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration(with_metaclass(TypeWithDefault, object)):
|
||||||
"""
|
"""
|
||||||
NOTE: This class is auto generated by the swagger code generator program.
|
NOTE: This class is auto generated by the swagger code generator program.
|
||||||
Ref: https://github.com/swagger-api/swagger-codegen
|
Ref: https://github.com/swagger-api/swagger-codegen
|
||||||
@ -75,6 +91,16 @@ class Configuration(object):
|
|||||||
self.cert_file = None
|
self.cert_file = None
|
||||||
# client key file
|
# client key file
|
||||||
self.key_file = None
|
self.key_file = None
|
||||||
|
# Set this to True/False to enable/disable SSL hostname verification.
|
||||||
|
self.assert_hostname = None
|
||||||
|
|
||||||
|
# urllib3 connection pool's maximum number of connections saved
|
||||||
|
# per pool. urllib3 uses 1 connection as default value, but this is
|
||||||
|
# not the best value when you are making a lot of possibly parallel
|
||||||
|
# requests to the same host, which is often the case here.
|
||||||
|
# cpu_count * 5 is used as default value to increase performance.
|
||||||
|
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
|
||||||
|
|
||||||
|
|
||||||
# Proxy URL
|
# Proxy URL
|
||||||
self.proxy = None
|
self.proxy = None
|
||||||
|
@ -56,7 +56,7 @@ class RESTResponse(io.IOBase):
|
|||||||
|
|
||||||
class RESTClientObject(object):
|
class RESTClientObject(object):
|
||||||
|
|
||||||
def __init__(self, configuration, pools_size=4, maxsize=4):
|
def __init__(self, configuration, pools_size=4, maxsize=None):
|
||||||
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
||||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75
|
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75
|
||||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680
|
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680
|
||||||
@ -76,6 +76,16 @@ class RESTClientObject(object):
|
|||||||
# if not set certificate file, use Mozilla's root certificates.
|
# if not set certificate file, use Mozilla's root certificates.
|
||||||
ca_certs = certifi.where()
|
ca_certs = certifi.where()
|
||||||
|
|
||||||
|
addition_pool_args = {}
|
||||||
|
if configuration.assert_hostname is not None:
|
||||||
|
addition_pool_args['assert_hostname'] = configuration.assert_hostname
|
||||||
|
|
||||||
|
if maxsize is None:
|
||||||
|
if configuration.connection_pool_maxsize is not None:
|
||||||
|
maxsize = configuration.connection_pool_maxsize
|
||||||
|
else:
|
||||||
|
maxsize = 4
|
||||||
|
|
||||||
# https pool manager
|
# https pool manager
|
||||||
if configuration.proxy:
|
if configuration.proxy:
|
||||||
self.pool_manager = urllib3.ProxyManager(
|
self.pool_manager = urllib3.ProxyManager(
|
||||||
@ -85,7 +95,8 @@ class RESTClientObject(object):
|
|||||||
ca_certs=ca_certs,
|
ca_certs=ca_certs,
|
||||||
cert_file=configuration.cert_file,
|
cert_file=configuration.cert_file,
|
||||||
key_file=configuration.key_file,
|
key_file=configuration.key_file,
|
||||||
proxy_url=configuration.proxy
|
proxy_url=configuration.proxy,
|
||||||
|
**addition_pool_args
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.pool_manager = urllib3.PoolManager(
|
self.pool_manager = urllib3.PoolManager(
|
||||||
@ -94,7 +105,8 @@ class RESTClientObject(object):
|
|||||||
cert_reqs=cert_reqs,
|
cert_reqs=cert_reqs,
|
||||||
ca_certs=ca_certs,
|
ca_certs=ca_certs,
|
||||||
cert_file=configuration.cert_file,
|
cert_file=configuration.cert_file,
|
||||||
key_file=configuration.key_file
|
key_file=configuration.key_file,
|
||||||
|
**addition_pool_args
|
||||||
)
|
)
|
||||||
|
|
||||||
def request(self, method, url, query_params=None, headers=None,
|
def request(self, method, url, query_params=None, headers=None,
|
||||||
|
@ -29,7 +29,7 @@ SWGFakeApi::SWGFakeApi(QString host, QString basePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \r(QString* test_code_inject____end____rn_n_r) {
|
SWGFakeApi::testCodeInject____end__rn_n_r(QString* test_code_inject____end____rn_n_r) {
|
||||||
QString fullPath;
|
QString fullPath;
|
||||||
fullPath.append(this->host).append(this->basePath).append("/fake");
|
fullPath.append(this->host).append(this->basePath).append("/fake");
|
||||||
|
|
||||||
@ -45,16 +45,20 @@ SWGFakeApi::testCodeInject */ ' " =end \r\n \n \r(QString* test_c
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach(QString key, this->defaultHeaders.keys()) {
|
||||||
|
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||||
|
}
|
||||||
|
|
||||||
connect(worker,
|
connect(worker,
|
||||||
&HttpRequestWorker::on_execution_finished,
|
&HttpRequestWorker::on_execution_finished,
|
||||||
this,
|
this,
|
||||||
&SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback);
|
&SWGFakeApi::testCodeInject____end__rn_n_rCallback);
|
||||||
|
|
||||||
worker->execute(&input);
|
worker->execute(&input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpRequestWorker * worker) {
|
SWGFakeApi::testCodeInject____end__rn_n_rCallback(HttpRequestWorker * worker) {
|
||||||
QString msg;
|
QString msg;
|
||||||
QString error_str = worker->error_str;
|
QString error_str = worker->error_str;
|
||||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||||
@ -68,8 +72,12 @@ SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpReq
|
|||||||
|
|
||||||
worker->deleteLater();
|
worker->deleteLater();
|
||||||
|
|
||||||
emit testCodeInject */ ' " =end \r\n \n \rSignal();
|
if (worker->error_type == QNetworkReply::NoError) {
|
||||||
emit testCodeInject */ ' " =end \r\n \n \rSignalE(error_type, error_str);
|
emit testCodeInject____end__rn_n_rSignal();
|
||||||
|
} else {
|
||||||
|
emit testCodeInject____end__rn_n_rSignalE(error_type, error_str);
|
||||||
|
emit testCodeInject____end__rn_n_rSignalEFull(worker, error_type, error_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,16 +31,19 @@ public:
|
|||||||
|
|
||||||
QString host;
|
QString host;
|
||||||
QString basePath;
|
QString basePath;
|
||||||
|
QMap<QString, QString> defaultHeaders;
|
||||||
|
|
||||||
void testCodeInject */ ' " =end \r\n \n \r(QString* test_code_inject____end____rn_n_r);
|
void testCodeInject____end__rn_n_r(QString* test_code_inject____end____rn_n_r);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void testCodeInject */ ' " =end \r\n \n \rCallback (HttpRequestWorker * worker);
|
void testCodeInject____end__rn_n_rCallback (HttpRequestWorker * worker);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void testCodeInject */ ' " =end \r\n \n \rSignal();
|
void testCodeInject____end__rn_n_rSignal();
|
||||||
|
|
||||||
void testCodeInject */ ' " =end \r\n \n \rSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
void testCodeInject____end__rn_n_rSignalE(QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
|
void testCodeInject____end__rn_n_rSignalEFull(HttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,6 +262,9 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
|
|||||||
// prepare connection
|
// prepare connection
|
||||||
|
|
||||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||||
|
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
||||||
|
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
|
||||||
|
}
|
||||||
request.setRawHeader("User-Agent", "Swagger-Client");
|
request.setRawHeader("User-Agent", "Swagger-Client");
|
||||||
foreach(QString key, input->headers.keys()) {
|
foreach(QString key, input->headers.keys()) {
|
||||||
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
|
request.setRawHeader(key.toStdString().c_str(), input->headers.value(key).toStdString().c_str());
|
||||||
@ -309,16 +312,14 @@ void HttpRequestWorker::execute(HttpRequestInput *input) {
|
|||||||
|
|
||||||
void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
void HttpRequestWorker::on_manager_finished(QNetworkReply *reply) {
|
||||||
error_type = reply->error();
|
error_type = reply->error();
|
||||||
if (error_type == QNetworkReply::NoError) {
|
response = reply->readAll();
|
||||||
response = reply->readAll();
|
error_str = reply->errorString();
|
||||||
}
|
|
||||||
else {
|
|
||||||
error_str = reply->errorString();
|
|
||||||
}
|
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
emit on_execution_finished(this);
|
emit on_execution_finished(this);
|
||||||
}
|
}
|
||||||
|
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
|
|
||||||
QString http_attribute_encode(QString attribute_name, QString input);
|
QString http_attribute_encode(QString attribute_name, QString input);
|
||||||
void execute(HttpRequestInput *input);
|
void execute(HttpRequestInput *input);
|
||||||
|
static QSslConfiguration* sslDefaultConfiguration;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void on_execution_finished(HttpRequestWorker *worker);
|
void on_execution_finished(HttpRequestWorker *worker);
|
||||||
|
@ -37,7 +37,7 @@ SWGReturn::~SWGReturn() {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGReturn::init() {
|
SWGReturn::init() {
|
||||||
return = 0;
|
_return = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -56,7 +56,7 @@ SWGReturn::fromJson(QString &json) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
SWGReturn::fromJsonObject(QJsonObject &pJson) {
|
SWGReturn::fromJsonObject(QJsonObject &pJson) {
|
||||||
::Swagger::setValue(&return, pJson["return"], "qint32", "");
|
::Swagger::setValue(&_return, pJson["return"], "qint32", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
@ -73,18 +73,18 @@ QJsonObject*
|
|||||||
SWGReturn::asJsonObject() {
|
SWGReturn::asJsonObject() {
|
||||||
QJsonObject* obj = new QJsonObject();
|
QJsonObject* obj = new QJsonObject();
|
||||||
|
|
||||||
obj->insert("return", QJsonValue(return));
|
obj->insert("return", QJsonValue(_return));
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32
|
qint32
|
||||||
SWGReturn::getReturn() {
|
SWGReturn::getReturn() {
|
||||||
return return;
|
return _return;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
SWGReturn::setReturn(qint32 return) {
|
SWGReturn::setReturn(qint32 _return) {
|
||||||
this->return = return;
|
this->_return = _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ public:
|
|||||||
SWGReturn* fromJson(QString &jsonString);
|
SWGReturn* fromJson(QString &jsonString);
|
||||||
|
|
||||||
qint32 getReturn();
|
qint32 getReturn();
|
||||||
void setReturn(qint32 return);
|
void setReturn(qint32 _return);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint32 return;
|
qint32 _return;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
@ -122,7 +123,9 @@ module Petstore
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Typhoeus::Request.new(url, req_opts)
|
request = Typhoeus::Request.new(url, req_opts)
|
||||||
|
download_file(request) if opts[:return_type] == 'File'
|
||||||
|
request
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if the given MIME is a JSON MIME.
|
# Check if the given MIME is a JSON MIME.
|
||||||
@ -143,14 +146,16 @@ module Petstore
|
|||||||
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
||||||
def deserialize(response, return_type)
|
def deserialize(response, return_type)
|
||||||
body = response.body
|
body = response.body
|
||||||
|
|
||||||
|
# handle file downloading - return the File instance processed in request callbacks
|
||||||
|
# note that response body is empty when the file is written in chunks in request on_body callback
|
||||||
|
return @tempfile if return_type == 'File'
|
||||||
|
|
||||||
return nil if body.nil? || body.empty?
|
return nil if body.nil? || body.empty?
|
||||||
|
|
||||||
# return response body directly for String return type
|
# return response body directly for String return type
|
||||||
return body if return_type == 'String'
|
return body if return_type == 'String'
|
||||||
|
|
||||||
# handle file downloading - save response body into a tmp file and return the File instance
|
|
||||||
return download_file(response) if return_type == 'File'
|
|
||||||
|
|
||||||
# ensuring a default content type
|
# ensuring a default content type
|
||||||
content_type = response.headers['Content-Type'] || 'application/json'
|
content_type = response.headers['Content-Type'] || 'application/json'
|
||||||
|
|
||||||
@ -213,30 +218,38 @@ module Petstore
|
|||||||
|
|
||||||
# Save response body into a file in (the defined) temporary folder, using the filename
|
# Save response body into a file in (the defined) temporary folder, using the filename
|
||||||
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
||||||
|
# The response body is written to the file in chunks in order to handle files which
|
||||||
|
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
||||||
|
# process can use.
|
||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
# @return [Tempfile] the file downloaded
|
def download_file(request)
|
||||||
def download_file(response)
|
|
||||||
content_disposition = response.headers['Content-Disposition']
|
|
||||||
if content_disposition and content_disposition =~ /filename=/i
|
|
||||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
|
||||||
prefix = sanitize_filename(filename)
|
|
||||||
else
|
|
||||||
prefix = 'download-'
|
|
||||||
end
|
|
||||||
prefix = prefix + '-' unless prefix.end_with?('-')
|
|
||||||
|
|
||||||
tempfile = nil
|
tempfile = nil
|
||||||
encoding = response.body.encoding
|
encoding = nil
|
||||||
Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
|
request.on_headers do |response|
|
||||||
file.write(response.body)
|
content_disposition = response.headers['Content-Disposition']
|
||||||
tempfile = file
|
if content_disposition and content_disposition =~ /filename=/i
|
||||||
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||||
|
prefix = sanitize_filename(filename)
|
||||||
|
else
|
||||||
|
prefix = 'download-'
|
||||||
|
end
|
||||||
|
prefix = prefix + '-' unless prefix.end_with?('-')
|
||||||
|
encoding = response.body.encoding
|
||||||
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
|
@tempfile = tempfile
|
||||||
|
end
|
||||||
|
request.on_body do |chunk|
|
||||||
|
chunk.force_encoding(encoding)
|
||||||
|
tempfile.write(chunk)
|
||||||
|
end
|
||||||
|
request.on_complete do |response|
|
||||||
|
tempfile.close
|
||||||
|
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
||||||
|
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
||||||
|
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
||||||
|
"explicitly with `tempfile.delete`"
|
||||||
end
|
end
|
||||||
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
|
||||||
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
|
||||||
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
|
||||||
"explicitly with `tempfile.delete`"
|
|
||||||
tempfile
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitize filename by removing path.
|
# Sanitize filename by removing path.
|
||||||
@ -267,7 +280,7 @@ module Petstore
|
|||||||
data = {}
|
data = {}
|
||||||
form_params.each do |key, value|
|
form_params.each do |key, value|
|
||||||
case value
|
case value
|
||||||
when File, Array, nil
|
when ::File, ::Array, nil
|
||||||
# let typhoeus handle File, Array and nil parameters
|
# let typhoeus handle File, Array and nil parameters
|
||||||
data[key] = value
|
data[key] = value
|
||||||
else
|
else
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
@ -75,6 +76,11 @@ module Petstore
|
|||||||
# Default to 0 (never times out).
|
# Default to 0 (never times out).
|
||||||
attr_accessor :timeout
|
attr_accessor :timeout
|
||||||
|
|
||||||
|
# Set this to false to skip client side validation in the operation.
|
||||||
|
# Default to true.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :client_side_validation
|
||||||
|
|
||||||
### TLS/SSL setting
|
### TLS/SSL setting
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
# Default to true.
|
# Default to true.
|
||||||
@ -128,6 +134,7 @@ module Petstore
|
|||||||
@api_key = {}
|
@api_key = {}
|
||||||
@api_key_prefix = {}
|
@api_key_prefix = {}
|
||||||
@timeout = 0
|
@timeout = 0
|
||||||
|
@client_side_validation = true
|
||||||
@verify_ssl = true
|
@verify_ssl = true
|
||||||
@verify_ssl_host = true
|
@verify_ssl_host = true
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
@ -28,15 +29,15 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.9"
|
s.required_ruby_version = ">= 1.9"
|
||||||
|
|
||||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
||||||
|
|
||||||
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
||||||
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
||||||
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
|
||||||
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
|
||||||
s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
|
s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
|
||||||
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
|
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
|
||||||
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.11'
|
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
|
||||||
|
|
||||||
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
|
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
|
||||||
s.test_files = `find spec/*`.split("\n")
|
s.test_files = `find spec/*`.split("\n")
|
||||||
|
@ -153,7 +153,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.module</groupId>
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
<artifactId>jackson-module-scala_2.10</artifactId>
|
<artifactId>jackson-module-scala_2.11</artifactId>
|
||||||
<version>${jackson-version}</version>
|
<version>${jackson-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -189,7 +189,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scalatest</groupId>
|
<groupId>org.scalatest</groupId>
|
||||||
<artifactId>scalatest_2.10</artifactId>
|
<artifactId>scalatest_2.11</artifactId>
|
||||||
<version>${scala-test-version}</version>
|
<version>${scala-test-version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -211,16 +211,16 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.wordnik.swagger</groupId>
|
<groupId>com.wordnik.swagger</groupId>
|
||||||
<artifactId>swagger-async-httpclient_2.10</artifactId>
|
<artifactId>swagger-async-httpclient_2.11</artifactId>
|
||||||
<version>${swagger-async-httpclient-version}</version>
|
<version>${swagger-async-httpclient-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<scala-version>2.10.4</scala-version>
|
<scala-version>2.11.11</scala-version>
|
||||||
<joda-version>1.2</joda-version>
|
<joda-version>1.2</joda-version>
|
||||||
<joda-time-version>2.2</joda-time-version>
|
<joda-time-version>2.2</joda-time-version>
|
||||||
<jersey-version>1.19</jersey-version>
|
<jersey-version>1.19</jersey-version>
|
||||||
<swagger-core-version>1.5.15</swagger-core-version>
|
<swagger-core-version>1.5.16</swagger-core-version>
|
||||||
<jersey-async-version>1.0.5</jersey-async-version>
|
<jersey-async-version>1.0.5</jersey-async-version>
|
||||||
<maven-plugin.version>1.0.0</maven-plugin.version>
|
<maven-plugin.version>1.0.0</maven-plugin.version>
|
||||||
<jackson-version>2.8.9</jackson-version>
|
<jackson-version>2.8.9</jackson-version>
|
||||||
|
@ -28,7 +28,7 @@ import java.util.UUID
|
|||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.MediaType
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import scala.collection.mutable.HashMap
|
import scala.collection.mutable
|
||||||
|
|
||||||
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
||||||
import com.fasterxml.jackson.datatype.joda.JodaModule
|
import com.fasterxml.jackson.datatype.joda.JodaModule
|
||||||
@ -41,8 +41,8 @@ object ScalaJsonUtil {
|
|||||||
def getJsonMapper = {
|
def getJsonMapper = {
|
||||||
val mapper = new ObjectMapper()
|
val mapper = new ObjectMapper()
|
||||||
mapper.registerModule(new DefaultScalaModule())
|
mapper.registerModule(new DefaultScalaModule())
|
||||||
mapper.registerModule(new JodaModule());
|
mapper.registerModule(new JodaModule())
|
||||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
@ -52,13 +52,14 @@ object ScalaJsonUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||||
httpHeaders: HashMap[String, String] = HashMap(),
|
httpHeaders: mutable.HashMap[String, String] = mutable.HashMap(),
|
||||||
hostMap: HashMap[String, Client] = HashMap(),
|
hostMap: mutable.HashMap[String, Client] = mutable.HashMap(),
|
||||||
asyncHttpClient: Boolean = false,
|
asyncHttpClient: Boolean = false,
|
||||||
authScheme: String = "",
|
authScheme: String = "",
|
||||||
authPreemptive: Boolean = false) {
|
authPreemptive: Boolean = false
|
||||||
|
) {
|
||||||
|
|
||||||
var defaultHeaders: HashMap[String, String] = httpHeaders
|
var defaultHeaders: mutable.HashMap[String, String] = httpHeaders
|
||||||
|
|
||||||
def escape(value: String): String = {
|
def escape(value: String): String = {
|
||||||
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||||
@ -68,11 +69,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
def escape(value: Long): String = value.toString
|
def escape(value: Long): String = value.toString
|
||||||
|
|
||||||
def escape(value: Double): String = value.toString
|
def escape(value: Double): String = value.toString
|
||||||
|
|
||||||
def escape(value: Float): String = value.toString
|
def escape(value: Float): String = value.toString
|
||||||
|
|
||||||
def escape(value: UUID): String = value.toString
|
def escape(value: UUID): String = value.toString
|
||||||
|
|
||||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||||
@ -89,16 +87,16 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
} else {
|
} else {
|
||||||
containerType.toLowerCase match {
|
containerType.toLowerCase match {
|
||||||
case "array" =>
|
case "array" =>
|
||||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
val typeInfo = mapper.getTypeFactory.constructCollectionType(classOf[java.util.List[_]], cls)
|
||||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||||
response.asScala.toList
|
response.asScala.toList
|
||||||
case "list" =>
|
case "list" =>
|
||||||
val typeInfo = mapper.getTypeFactory().constructCollectionType(classOf[java.util.List[_]], cls)
|
val typeInfo = mapper.getTypeFactory.constructCollectionType(classOf[java.util.List[_]], cls)
|
||||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||||
response.asScala.toList
|
response.asScala.toList
|
||||||
case _ =>
|
case _ =>
|
||||||
json match {
|
json match {
|
||||||
case e: String if ("\"\"" == e) => null
|
case e: String if "\"\"" == e => null
|
||||||
case _ => mapper.readValue(json, cls)
|
case _ => mapper.readValue(json, cls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,16 +109,27 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
|
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
|
||||||
case _ => mapper.writeValueAsString(obj)
|
case _ => mapper.writeValueAsString(obj)
|
||||||
}
|
}
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def invokeApi(host: String, path: String, method: String, queryParams: Map[String, String], formParams: Map[String, String], body: AnyRef, headerParams: Map[String, String], contentType: String): String = {
|
def invokeApi(
|
||||||
|
host: String,
|
||||||
|
path: String,
|
||||||
|
method: String,
|
||||||
|
queryParams: Map[String, String],
|
||||||
|
formParams: Map[String, String],
|
||||||
|
body: AnyRef,
|
||||||
|
headerParams: Map[String, String],
|
||||||
|
contentType: String
|
||||||
|
): String = {
|
||||||
val client = getClient(host)
|
val client = getClient(host)
|
||||||
|
|
||||||
val querystring = queryParams.filter(k => k._2 != null).map(k => (escape(k._1) + "=" + escape(k._2))).mkString("?", "&", "")
|
val querystring = queryParams.filter(k => k._2 != null).map(k => escape(k._1) + "=" + escape(k._2)).mkString("?", "&", "")
|
||||||
val builder = client.resource(host + path + querystring).accept(contentType)
|
val builder = client.resource(host + path + querystring).accept(contentType)
|
||||||
headerParams.map(p => builder.header(p._1, p._2))
|
headerParams.map(p => builder.header(p._1, p._2))
|
||||||
defaultHeaders.map(p => {
|
defaultHeaders.foreach(p => {
|
||||||
headerParams.contains(p._1) match {
|
headerParams.contains(p._1) match {
|
||||||
case true => // override default with supplied header
|
case true => // override default with supplied header
|
||||||
case false => if (p._2 != null) builder.header(p._1, p._2)
|
case false => if (p._2 != null) builder.header(p._1, p._2)
|
||||||
@ -129,18 +138,18 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
var formData: MultivaluedMapImpl = null
|
var formData: MultivaluedMapImpl = null
|
||||||
if (contentType == "application/x-www-form-urlencoded") {
|
if (contentType == "application/x-www-form-urlencoded") {
|
||||||
formData = new MultivaluedMapImpl()
|
formData = new MultivaluedMapImpl()
|
||||||
formParams.map(p => formData.add(p._1, p._2))
|
formParams.foreach(p => formData.add(p._1, p._2))
|
||||||
}
|
}
|
||||||
|
|
||||||
val response: ClientResponse = method match {
|
val response: ClientResponse = method match {
|
||||||
case "GET" => builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
case "GET" => builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
||||||
case "POST" =>
|
case "POST" =>
|
||||||
if (formData != null) {
|
if (formData != null && formData.size() > 0) {
|
||||||
builder.post(classOf[ClientResponse], formData)
|
builder.post(classOf[ClientResponse], formData)
|
||||||
} else if (body != null && body.isInstanceOf[File]) {
|
} else if (body != null && body.isInstanceOf[File]) {
|
||||||
val file = body.asInstanceOf[File]
|
val file = body.asInstanceOf[File]
|
||||||
val form = new FormDataMultiPart()
|
val form = new FormDataMultiPart()
|
||||||
form.field("filename", file.getName())
|
form.field("filename", file.getName)
|
||||||
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
||||||
builder.post(classOf[ClientResponse], form)
|
builder.post(classOf[ClientResponse], form)
|
||||||
} else {
|
} else {
|
||||||
@ -151,36 +160,37 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "PUT" =>
|
case "PUT" =>
|
||||||
if (formData != null) builder.post(classOf[ClientResponse], formData)
|
|
||||||
else if (body == null) builder.put(classOf[ClientResponse], null)
|
|
||||||
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
|
||||||
case "DELETE" => builder.delete(classOf[ClientResponse])
|
|
||||||
case "PATCH" => {
|
|
||||||
if (formData != null) {
|
if (formData != null) {
|
||||||
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], formData)
|
builder.post(classOf[ClientResponse], formData)
|
||||||
} else if (body == null) {
|
} else if (body == null) {
|
||||||
|
builder.put(classOf[ClientResponse], null)
|
||||||
|
} else {
|
||||||
|
builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
||||||
|
}
|
||||||
|
case "DELETE" => builder.delete(classOf[ClientResponse])
|
||||||
|
case "PATCH" =>
|
||||||
|
if(formData != null) {
|
||||||
|
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], formData)
|
||||||
|
} else if(body == null) {
|
||||||
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], null)
|
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], null)
|
||||||
} else {
|
} else {
|
||||||
builder.header("X-HTTP-Method-Override", "PATCH").`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
builder.header("X-HTTP-Method-Override", "PATCH").`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
response.getStatusInfo().getStatusCode() match {
|
response.getStatusInfo.getStatusCode match {
|
||||||
case 204 => ""
|
case 204 => ""
|
||||||
case code: Int if (Range(200, 299).contains(code)) =>
|
case code: Int if Range(200, 299).contains(code) =>
|
||||||
response.hasEntity() match {
|
response.hasEntity match {
|
||||||
case true => response.getEntity(classOf[String])
|
case true => response.getEntity(classOf[String])
|
||||||
case false => ""
|
case false => ""
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
val entity = response.hasEntity() match {
|
val entity = response.hasEntity match {
|
||||||
case true => response.getEntity(classOf[String])
|
case true => response.getEntity(classOf[String])
|
||||||
case false => "no data"
|
case false => "no data"
|
||||||
}
|
}
|
||||||
throw new ApiException(
|
throw new ApiException(response.getStatusInfo.getStatusCode, entity)
|
||||||
response.getStatusInfo().getStatusCode(),
|
|
||||||
entity)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +202,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
// client.addFilter(new LoggingFilter())
|
// client.addFilter(new LoggingFilter())
|
||||||
hostMap += host -> client
|
hostMap += host -> client
|
||||||
client
|
client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def newClient(host: String): Client = asyncHttpClient match {
|
def newClient(host: String): Client = asyncHttpClient match {
|
||||||
@ -204,9 +214,10 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||||
if (!authScheme.isEmpty) {
|
if (!authScheme.isEmpty) {
|
||||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||||
config.getAsyncHttpClientConfigBuilder
|
config
|
||||||
|
.getAsyncHttpClientConfigBuilder
|
||||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||||
.setUsePreemptiveAuth(authPreemptive).build)
|
.setUsePreemptiveAuth(authPreemptive).build)
|
||||||
}
|
}
|
||||||
AhcHttpClient.create(config)
|
AhcHttpClient.create(config)
|
||||||
case _ => Client.create()
|
case _ => Client.create()
|
||||||
@ -215,8 +226,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
|||||||
|
|
||||||
object ApiInvoker extends ApiInvoker(
|
object ApiInvoker extends ApiInvoker(
|
||||||
mapper = ScalaJsonUtil.getJsonMapper,
|
mapper = ScalaJsonUtil.getJsonMapper,
|
||||||
httpHeaders = HashMap(),
|
httpHeaders = mutable.HashMap(),
|
||||||
hostMap = HashMap(),
|
hostMap = mutable.HashMap(),
|
||||||
asyncHttpClient = false,
|
asyncHttpClient = false,
|
||||||
authScheme = "",
|
authScheme = "",
|
||||||
authPreemptive = false
|
authPreemptive = false
|
||||||
|
@ -40,8 +40,10 @@ import scala.concurrent._
|
|||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.util.{Failure, Success, Try}
|
import scala.util.{Failure, Success, Try}
|
||||||
|
|
||||||
class FakeApi(val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
class FakeApi(
|
||||||
defApiInvoker: ApiInvoker = ApiInvoker) {
|
val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
||||||
|
defApiInvoker: ApiInvoker = ApiInvoker
|
||||||
|
) {
|
||||||
|
|
||||||
implicit val formats = new org.json4s.DefaultFormats {
|
implicit val formats = new org.json4s.DefaultFormats {
|
||||||
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
|
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
|
||||||
@ -53,10 +55,12 @@ class FakeApi(val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =e
|
|||||||
implicit val stringWriter = RequestWriters.StringWriter
|
implicit val stringWriter = RequestWriters.StringWriter
|
||||||
implicit val jsonWriter = JsonFormatsWriter
|
implicit val jsonWriter = JsonFormatsWriter
|
||||||
|
|
||||||
var basePath = defBasePath
|
var basePath: String = defBasePath
|
||||||
var apiInvoker = defApiInvoker
|
var apiInvoker: ApiInvoker = defApiInvoker
|
||||||
|
|
||||||
def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value
|
def addHeader(key: String, value: String): mutable.HashMap[String, String] = {
|
||||||
|
apiInvoker.defaultHeaders += key -> value
|
||||||
|
}
|
||||||
|
|
||||||
val config = SwaggerConfig.forUrl(new URI(defBasePath))
|
val config = SwaggerConfig.forUrl(new URI(defBasePath))
|
||||||
val client = new RestClient(config)
|
val client = new RestClient(config)
|
||||||
@ -86,7 +90,6 @@ class FakeApi(val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =e
|
|||||||
helper.testCodeInject * ' " =end rn n r(testCodeInjectEndRnNR)
|
helper.testCodeInject * ' " =end rn n r(testCodeInjectEndRnNR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
class FakeApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
wwwroot/*.js
|
wwwroot/*.js
|
||||||
node_modules
|
node_modules
|
||||||
typings
|
typings
|
||||||
|
dist
|
||||||
|
@ -1 +1 @@
|
|||||||
2.2.3
|
2.3.0-SNAPSHOT
|
@ -1,7 +1,21 @@
|
|||||||
import * as api from './api/api';
|
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||||
import * as angular from 'angular';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { HttpModule } from '@angular/http';
|
||||||
|
import { Configuration } from './configuration';
|
||||||
|
|
||||||
const apiModule = angular.module('api', [])
|
import { FakeService } from './api/fake.service';
|
||||||
.service('FakeApi', api.FakeApi)
|
|
||||||
|
|
||||||
export default apiModule;
|
@NgModule({
|
||||||
|
imports: [ CommonModule, HttpModule ],
|
||||||
|
declarations: [],
|
||||||
|
exports: [],
|
||||||
|
providers: [ FakeService ]
|
||||||
|
})
|
||||||
|
export class ApiModule {
|
||||||
|
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||||
|
return {
|
||||||
|
ngModule: ApiModule,
|
||||||
|
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export * from './FakeApi';
|
export * from './fake.service';
|
||||||
import { FakeApi } from './FakeApi';
|
import { FakeService } from './fake.service';
|
||||||
export const APIS = [FakeApi];
|
export const APIS = [FakeService];
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
export * from './api/api';
|
export * from './api/api';
|
||||||
export * from './model/models';
|
export * from './model/models';
|
||||||
|
export * from './variables';
|
||||||
|
export * from './configuration';
|
||||||
|
export * from './api.module';
|
@ -10,7 +10,7 @@
|
|||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as models from './models';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
@ -19,6 +19,8 @@ export interface ModelReturn {
|
|||||||
/**
|
/**
|
||||||
* property description *_/ ' \" =end -- \\r\\n \\n \\r
|
* property description *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*/
|
*/
|
||||||
"return"?: number;
|
return?: number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
export * from './ModelReturn';
|
export * from './modelReturn';
|
||||||
|
@ -1 +1 @@
|
|||||||
2.2.3-SNAPSHOT
|
2.3.0-SNAPSHOT
|
@ -12,10 +12,10 @@ import { FakeService } from './api/fake.service';
|
|||||||
providers: [ FakeService ]
|
providers: [ FakeService ]
|
||||||
})
|
})
|
||||||
export class ApiModule {
|
export class ApiModule {
|
||||||
public static forConfig(configuration: Configuration): ModuleWithProviders {
|
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||||
return {
|
return {
|
||||||
ngModule: ApiModule,
|
ngModule: ApiModule,
|
||||||
providers: [ {provide: Configuration, useValue: configuration}]
|
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
import { Inject, Injectable, Optional } from '@angular/core';
|
import { Inject, Injectable, Optional } from '@angular/core';
|
||||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
|
||||||
import { Response, ResponseContentType } from '@angular/http';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import '../rxjs-operators';
|
import '../rxjs-operators';
|
||||||
@ -21,41 +21,26 @@ import '../rxjs-operators';
|
|||||||
|
|
||||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||||
import { Configuration } from '../configuration';
|
import { Configuration } from '../configuration';
|
||||||
|
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FakeService {
|
export class FakeService {
|
||||||
protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
|
||||||
public defaultHeaders: Headers = new Headers();
|
|
||||||
public configuration: Configuration = new Configuration();
|
|
||||||
|
|
||||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||||
|
public defaultHeaders = new HttpHeaders();
|
||||||
|
public configuration = new Configuration();
|
||||||
|
|
||||||
|
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
if (configuration) {
|
if (configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.basePath = basePath || configuration.basePath || this.basePath;
|
this.basePath = basePath || configuration.basePath || this.basePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Extends object by coping non-existing properties.
|
|
||||||
* @param objA object to be extended
|
|
||||||
* @param objB source object
|
|
||||||
*/
|
|
||||||
private extendObj<T1,T2>(objA: T1, objB: T2) {
|
|
||||||
for(let key in objB){
|
|
||||||
if(objB.hasOwnProperty(key)){
|
|
||||||
(objA as any)[key] = (objB as any)[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return <T1&T2>objA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param consumes string[] mime-types
|
* @param consumes string[] mime-types
|
||||||
* @return true: consumes contains 'multipart/form-data', false: otherwise
|
* @return true: consumes contains 'multipart/form-data', false: otherwise
|
||||||
@ -70,21 +55,6 @@ export class FakeService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
|
||||||
*
|
|
||||||
* @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
|
||||||
*/
|
|
||||||
public testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, extraHttpRequestParams?: any): Observable<{}> {
|
|
||||||
return this.testCodeInjectEndRnNRWithHttpInfo(test code inject * ' " =end rn n r, extraHttpRequestParams)
|
|
||||||
.map((response: Response) => {
|
|
||||||
if (response.status === 204) {
|
|
||||||
return undefined;
|
|
||||||
} else {
|
|
||||||
return response.json() || {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,47 +62,37 @@ export class FakeService {
|
|||||||
*
|
*
|
||||||
* @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
* @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*/
|
*/
|
||||||
public testCodeInjectEndRnNRWithHttpInfo(test code inject * ' " =end rn n r?: string, extraHttpRequestParams?: any): Observable<Response> {
|
public testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string): Observable<{}> {
|
||||||
const path = this.basePath + '/fake';
|
|
||||||
|
|
||||||
let queryParameters = new URLSearchParams();
|
let headers = this.defaultHeaders;
|
||||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
let consumes: string[] = [
|
let consumes: string[] = [
|
||||||
'application/json',
|
'application/json',
|
||||||
'*_/ =end -- '
|
'*_/ =end -- '
|
||||||
];
|
];
|
||||||
let canConsumeForm = this.canConsumeForm(consumes);
|
const canConsumeForm = this.canConsumeForm(consumes);
|
||||||
|
|
||||||
|
let formParams: { append(param: string, value: any): void; };
|
||||||
let useForm = false;
|
let useForm = false;
|
||||||
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
|
let convertFormParamsToString = false;
|
||||||
set(param: string, value: any): void;
|
if (useForm) {
|
||||||
};
|
formParams = new FormData();
|
||||||
|
} else {
|
||||||
|
formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// to determine the Accept header
|
|
||||||
let produces: string[] = [
|
|
||||||
'application/json',
|
|
||||||
'*_/ =end -- '
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
if (test code inject * ' " =end rn n r !== undefined) {
|
if (test code inject * ' " =end rn n r !== undefined) {
|
||||||
formParams.set('test code inject */ ' " =end -- \r\n \n \r', <any>test code inject * ' " =end rn n r);
|
formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', <any>test code inject * ' " =end rn n r) || formParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
return this.httpClient.put<any>(`${this.basePath}/fake`,
|
||||||
method: RequestMethod.Put,
|
convertFormParamsToString ? formParams.toString() : formParams, {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: formParams.toString(),
|
withCredentials: this.configuration.withCredentials,
|
||||||
search: queryParameters,
|
|
||||||
withCredentials:this.configuration.withCredentials
|
|
||||||
});
|
});
|
||||||
// https://github.com/swagger-api/swagger-codegen/issues/4037
|
|
||||||
if (extraHttpRequestParams) {
|
|
||||||
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.http.request(path, requestOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,18 @@ export interface ConfigurationParameters {
|
|||||||
apiKeys?: {[ key: string ]: string};
|
apiKeys?: {[ key: string ]: string};
|
||||||
username?: string;
|
username?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
accessToken?: string;
|
accessToken?: string | (() => string);
|
||||||
basePath?: string;
|
basePath?: string;
|
||||||
withCredentials?: boolean;
|
withCredentials?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Configuration {
|
export class Configuration {
|
||||||
apiKeys: {[ key: string ]: string};
|
apiKeys?: {[ key: string ]: string};
|
||||||
username: string;
|
username?: string;
|
||||||
password: string;
|
password?: string;
|
||||||
accessToken: string | (() => string);
|
accessToken?: string | (() => string);
|
||||||
basePath: string;
|
basePath?: string;
|
||||||
withCredentials: boolean;
|
withCredentials?: boolean;
|
||||||
|
|
||||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||||
this.apiKeys = configurationParameters.apiKeys;
|
this.apiKeys = configurationParameters.apiKeys;
|
||||||
|
@ -22,3 +22,5 @@ export interface ModelReturn {
|
|||||||
return?: number;
|
return?: number;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { InjectionToken<string> } from '@angular/core';
|
import { InjectionToken } from '@angular/core';
|
||||||
|
|
||||||
export const BASE_PATH = new InjectionToken<string>('basePath');
|
export const BASE_PATH = new InjectionToken<string>('basePath');
|
||||||
export const COLLECTION_FORMATS = {
|
export const COLLECTION_FORMATS = {
|
||||||
@ -6,4 +6,4 @@ export const COLLECTION_FORMATS = {
|
|||||||
'tsv': ' ',
|
'tsv': ' ',
|
||||||
'ssv': ' ',
|
'ssv': ' ',
|
||||||
'pipes': '|'
|
'pipes': '|'
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import * as url from "url";
|
import * as url from "url";
|
||||||
import * as isomorphicFetch from "isomorphic-fetch";
|
import * as isomorphicFetch from "isomorphic-fetch";
|
||||||
@ -18,7 +18,11 @@ import { Configuration } from "./configuration";
|
|||||||
|
|
||||||
const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, "");
|
const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, "");
|
||||||
|
|
||||||
const COLLECTION_FORMATS = {
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
csv: ",",
|
csv: ",",
|
||||||
ssv: " ",
|
ssv: " ",
|
||||||
tsv: "\t",
|
tsv: "\t",
|
||||||
@ -102,26 +106,28 @@ export const FakeApiFetchParamCreator = function (configuration?: Configuration)
|
|||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, options: any = {}): FetchArgs {
|
testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, options: any = {}): FetchArgs {
|
||||||
const path = `/fake`;
|
const localVarPath = `/fake`;
|
||||||
const urlObj = url.parse(path, true);
|
const localVarUrlObj = url.parse(localVarPath, true);
|
||||||
const requestOptions = Object.assign({ method: 'PUT' }, options);
|
const localVarRequestOptions = Object.assign({ method: 'PUT' }, options);
|
||||||
const headerParameter = {} as any;
|
const localVarHeaderParameter = {} as any;
|
||||||
const queryParameter = {} as any;
|
const localVarQueryParameter = {} as any;
|
||||||
const formParams = new url.URLSearchParams();
|
const localVarFormParams = new url.URLSearchParams();
|
||||||
|
|
||||||
if (test code inject * ' " =end rn n r !== undefined) {
|
if (test code inject * ' " =end rn n r !== undefined) {
|
||||||
formParams.set('test code inject */ ' " =end -- \r\n \n \r', test code inject * ' " =end rn n r as any);
|
localVarFormParams.set('test code inject */ ' " =end -- \r\n \n \r', test code inject * ' " =end rn n r as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParameter['Content-Type'] = 'application/x-www-form-urlencoded';
|
localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
|
|
||||||
urlObj.query = Object.assign({}, urlObj.query, queryParameter, options.query);
|
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
||||||
requestOptions.headers = Object.assign({}, headerParameter, options.headers);
|
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||||
requestOptions.body = formParams.toString();
|
delete localVarUrlObj.search;
|
||||||
|
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
||||||
|
localVarRequestOptions.body = localVarFormParams.toString();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: url.format(urlObj),
|
url: url.format(localVarUrlObj),
|
||||||
options: requestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -141,9 +147,9 @@ export const FakeApiFp = function(configuration?: Configuration) {
|
|||||||
* @throws {RequiredError}
|
* @throws {RequiredError}
|
||||||
*/
|
*/
|
||||||
testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
|
testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
|
||||||
const fetchArgs = FakeApiFetchParamCreator(configuration).testCodeInjectEndRnNR(test code inject * ' " =end rn n r, options);
|
const localVarFetchArgs = FakeApiFetchParamCreator(configuration).testCodeInjectEndRnNR(test code inject * ' " =end rn n r, options);
|
||||||
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
|
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
|
||||||
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
|
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return response;
|
return response;
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
export interface ConfigurationParameters {
|
||||||
apiKey?: string | ((name: string) => string);
|
apiKey?: string | ((name: string) => string);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export * from "./api";
|
export * from "./api";
|
||||||
export * from "./configuration";
|
export * from "./configuration";
|
||||||
|
@ -269,8 +269,8 @@ export class FakeApi {
|
|||||||
this.authentications.petstore_auth.accessToken = token;
|
this.authentications.petstore_auth.accessToken = token;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
|
||||||
*
|
*
|
||||||
|
* @summary To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
* @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
* @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
*/
|
*/
|
||||||
public testCodeInjectEndRnNR (test code inject * ' " =end rn n r?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
public testCodeInjectEndRnNR (test code inject * ' " =end rn n r?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||||
@ -280,7 +280,6 @@ export class FakeApi {
|
|||||||
let formParams: any = {};
|
let formParams: any = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let useFormData = false;
|
let useFormData = false;
|
||||||
|
|
||||||
if (test code inject * ' " =end rn n r !== undefined) {
|
if (test code inject * ' " =end rn n r !== undefined) {
|
||||||
|
@ -9,7 +9,7 @@ $app = new Silex\Application();
|
|||||||
|
|
||||||
|
|
||||||
$app->PUT('/v2 *_/ ' \" =end -- \\r\\n \\n \\r/fake', function(Application $app, Request $request) {
|
$app->PUT('/v2 *_/ ' \" =end -- \\r\\n \\n \\r/fake', function(Application $app, Request $request) {
|
||||||
$test code inject */ ' " =end __ \r\n \n \r = $request->get('test code inject */ ' " =end __ \r\n \n \r');
|
$test_code_inject_*/_'_"_=end____\r\n_\n_\r = $request->get('test_code_inject_*/_'_"_=end____\r\n_\n_\r');
|
||||||
return new Response('How about implementing testCodeInject */ ' " =end \r\n \n \r as a PUT method ?');
|
return new Response('How about implementing testCodeInject */ ' " =end \r\n \n \r as a PUT method ?');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user