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.
|
||||
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
|
||||
|
@ -26,6 +26,6 @@ fi
|
||||
|
||||
# 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"
|
||||
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
|
||||
|
@ -138,16 +138,9 @@ namespace IO.Swagger.Client
|
||||
}
|
||||
|
||||
if (postBody != null) // http body (model or byte[]) parameter
|
||||
{
|
||||
if (postBody.GetType() == typeof(String))
|
||||
{
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||
}
|
||||
else if (postBody.GetType() == typeof(byte[]))
|
||||
{
|
||||
request.AddParameter(contentType, postBody, ParameterType.RequestBody);
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
/// 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'
|
||||
/// </summary>
|
||||
/// <param name="contentTypes">The Content-Type array to select from.</param>
|
||||
@ -361,11 +370,14 @@ namespace IO.Swagger.Client
|
||||
public String SelectHeaderContentType(String[] contentTypes)
|
||||
{
|
||||
if (contentTypes.Length == 0)
|
||||
return null;
|
||||
|
||||
if (contentTypes.Contains("application/json", StringComparer.OrdinalIgnoreCase))
|
||||
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'
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
*
|
||||
* 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
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package swagger
|
||||
|
@ -3,9 +3,9 @@
|
||||
*
|
||||
* 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
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package swagger
|
||||
|
@ -3,9 +3,9 @@
|
||||
*
|
||||
* 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
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package swagger
|
||||
|
@ -3,9 +3,9 @@
|
||||
*
|
||||
* 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
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package swagger
|
||||
|
@ -3,9 +3,9 @@
|
||||
*
|
||||
* 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
|
||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package swagger
|
||||
|
@ -8,7 +8,7 @@
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
@ -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
|
||||
```
|
||||
|
||||
##### 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
|
||||
#
|
||||
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 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
|
||||
browserify main.js > bundle.js
|
||||
@ -45,6 +70,24 @@ browserify main.js > bundle.js
|
||||
|
||||
Then include *bundle.js* in the HTML pages.
|
||||
|
||||
### Webpack Configuration
|
||||
|
||||
Using Webpack you may encounter the following error: "Module not found: Error:
|
||||
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
|
||||
the following section to your webpack config:
|
||||
|
||||
```javascript
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
parser: {
|
||||
amd: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation](#installation) instruction and execute the following JS code:
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "swagger_petstore____end____rn_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______",
|
||||
"license": "Unlicense",
|
||||
"license": "Apache-2.0 */ ' " =end -- \r\n \n \r",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "./node_modules/mocha/bin/mocha --recursive"
|
||||
|
@ -8,7 +8,7 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* 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.
|
||||
*
|
||||
@ -362,6 +362,7 @@
|
||||
* @param {String} httpMethod The HTTP method to use.
|
||||
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
|
||||
* @param {Object.<String, Object>} queryParams A map of query parameters and their values.
|
||||
* @param {Object.<String, Object>} collectionQueryParams A map of collection query parameters and their values.
|
||||
* @param {Object.<String, Object>} headerParams A map of header parameters and their values.
|
||||
* @param {Object.<String, Object>} formParams A map of form parameters and their values.
|
||||
* @param {Object} bodyParam The value to pass as the request body.
|
||||
@ -374,7 +375,7 @@
|
||||
* @returns {Object} The SuperAgent request object.
|
||||
*/
|
||||
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) {
|
||||
|
||||
var _this = this;
|
||||
@ -384,6 +385,25 @@
|
||||
// apply authentications
|
||||
this.applyAuthToRequest(request, authNames);
|
||||
|
||||
// set collection query parameters
|
||||
for (var key in collectionQueryParams) {
|
||||
if (collectionQueryParams.hasOwnProperty(key)) {
|
||||
var param = collectionQueryParams[key];
|
||||
if (param.collectionFormat === 'csv') {
|
||||
// SuperAgent normally percent-encodes all reserved characters in a query parameter. However,
|
||||
// commas are used as delimiters for the 'csv' collectionFormat so they must not be encoded. We
|
||||
// must therefore construct and encode 'csv' collection query parameters manually.
|
||||
if (param.value != null) {
|
||||
var value = param.value.map(this.paramToString).map(encodeURIComponent).join(',');
|
||||
request.query(encodeURIComponent(key) + "=" + value);
|
||||
}
|
||||
} else {
|
||||
// All other collection query parameters should be treated as ordinary query parameters.
|
||||
queryParams[key] = this.buildCollectionParam(param.value, param.collectionFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set query parameters
|
||||
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
||||
queryParams['_'] = new Date().getTime();
|
||||
|
@ -8,7 +8,7 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* 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.
|
||||
*
|
||||
@ -71,6 +71,8 @@
|
||||
};
|
||||
var queryParams = {
|
||||
};
|
||||
var collectionQueryParams = {
|
||||
};
|
||||
var headerParams = {
|
||||
};
|
||||
var formParams = {
|
||||
@ -84,7 +86,7 @@
|
||||
|
||||
return this.apiClient.callApi(
|
||||
'/fake', 'PUT',
|
||||
pathParams, queryParams, headerParams, formParams, postBody,
|
||||
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
|
||||
authNames, contentTypes, accepts, returnType, callback
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* 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.
|
||||
*
|
||||
|
@ -8,7 +8,7 @@
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* 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.
|
||||
*
|
||||
|
@ -251,10 +251,10 @@ use WWW::SwaggerClient::;
|
||||
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 {
|
||||
$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 ($@) {
|
||||
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 $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 {
|
||||
$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 ($@) {
|
||||
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 __ \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
|
||||
|
||||
@ -24,10 +24,10 @@ use Something::Deep::FakeApi;
|
||||
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 {
|
||||
$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 ($@) {
|
||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||
@ -38,7 +38,7 @@ if ($@) {
|
||||
|
||||
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
|
||||
|
||||
|
@ -53,10 +53,10 @@ sub new {
|
||||
#
|
||||
# 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 = {
|
||||
'test code inject */ ' " =end __ \r\n \n \r' => {
|
||||
'test_code_inject_*/_'_"_=end____\r\n_\n_\r' => {
|
||||
data_type => 'string',
|
||||
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
||||
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 -- ');
|
||||
|
||||
# form params
|
||||
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'});
|
||||
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'});
|
||||
}
|
||||
|
||||
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 __ \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
|
||||
|
||||
@ -24,10 +24,10 @@ use WWW::SwaggerClient::FakeApi;
|
||||
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 {
|
||||
$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 ($@) {
|
||||
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
|
||||
@ -38,7 +38,7 @@ if ($@) {
|
||||
|
||||
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
|
||||
|
||||
|
@ -53,10 +53,10 @@ sub new {
|
||||
#
|
||||
# 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 = {
|
||||
'test code inject */ ' " =end __ \r\n \n \r' => {
|
||||
'test_code_inject_*/_'_"_=end____\r\n_\n_\r' => {
|
||||
data_type => 'string',
|
||||
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
|
||||
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 -- ');
|
||||
|
||||
# form params
|
||||
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'});
|
||||
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'});
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
@ -283,7 +283,7 @@ class ApiClient(object):
|
||||
_request_timeout=None):
|
||||
"""
|
||||
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 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
|
||||
timeout. It can also be a pair (tuple) of (connection, read) timeouts.
|
||||
:return:
|
||||
If provide parameter callback,
|
||||
If async parameter is True,
|
||||
the request will be called asynchronously.
|
||||
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.
|
||||
"""
|
||||
if not async:
|
||||
|
@ -15,14 +15,30 @@ from __future__ import absolute_import
|
||||
|
||||
import urllib3
|
||||
|
||||
import sys
|
||||
import copy
|
||||
import logging
|
||||
import multiprocessing
|
||||
import sys
|
||||
|
||||
from six import iteritems
|
||||
from six import with_metaclass
|
||||
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.
|
||||
Ref: https://github.com/swagger-api/swagger-codegen
|
||||
@ -75,6 +91,16 @@ class Configuration(object):
|
||||
self.cert_file = None
|
||||
# client key file
|
||||
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
|
||||
self.proxy = None
|
||||
|
@ -56,7 +56,7 @@ class RESTResponse(io.IOBase):
|
||||
|
||||
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
|
||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75
|
||||
# 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.
|
||||
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
|
||||
if configuration.proxy:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
@ -85,7 +95,8 @@ class RESTClientObject(object):
|
||||
ca_certs=ca_certs,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy
|
||||
proxy_url=configuration.proxy,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
@ -94,7 +105,8 @@ class RESTClientObject(object):
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=ca_certs,
|
||||
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,
|
||||
|
@ -29,7 +29,7 @@ SWGFakeApi::SWGFakeApi(QString host, QString basePath) {
|
||||
}
|
||||
|
||||
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;
|
||||
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,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback);
|
||||
&SWGFakeApi::testCodeInject____end__rn_n_rCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpRequestWorker * worker) {
|
||||
SWGFakeApi::testCodeInject____end__rn_n_rCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
@ -68,8 +72,12 @@ SWGFakeApi::testCodeInject */ ' " =end \r\n \n \rCallback(HttpReq
|
||||
|
||||
worker->deleteLater();
|
||||
|
||||
emit testCodeInject */ ' " =end \r\n \n \rSignal();
|
||||
emit testCodeInject */ ' " =end \r\n \n \rSignalE(error_type, error_str);
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
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 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:
|
||||
void testCodeInject */ ' " =end \r\n \n \rCallback (HttpRequestWorker * worker);
|
||||
void testCodeInject____end__rn_n_rCallback (HttpRequestWorker * worker);
|
||||
|
||||
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
|
||||
|
||||
QNetworkRequest request = QNetworkRequest(QUrl(input->url_str));
|
||||
if (HttpRequestWorker::sslDefaultConfiguration != nullptr) {
|
||||
request.setSslConfiguration(*HttpRequestWorker::sslDefaultConfiguration);
|
||||
}
|
||||
request.setRawHeader("User-Agent", "Swagger-Client");
|
||||
foreach(QString key, input->headers.keys()) {
|
||||
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) {
|
||||
error_type = reply->error();
|
||||
if (error_type == QNetworkReply::NoError) {
|
||||
response = reply->readAll();
|
||||
}
|
||||
else {
|
||||
error_str = reply->errorString();
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
emit on_execution_finished(this);
|
||||
}
|
||||
QSslConfiguration* HttpRequestWorker::sslDefaultConfiguration;
|
||||
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
|
||||
QString http_attribute_encode(QString attribute_name, QString input);
|
||||
void execute(HttpRequestInput *input);
|
||||
static QSslConfiguration* sslDefaultConfiguration;
|
||||
|
||||
signals:
|
||||
void on_execution_finished(HttpRequestWorker *worker);
|
||||
|
@ -37,7 +37,7 @@ SWGReturn::~SWGReturn() {
|
||||
|
||||
void
|
||||
SWGReturn::init() {
|
||||
return = 0;
|
||||
_return = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -56,7 +56,7 @@ SWGReturn::fromJson(QString &json) {
|
||||
|
||||
void
|
||||
SWGReturn::fromJsonObject(QJsonObject &pJson) {
|
||||
::Swagger::setValue(&return, pJson["return"], "qint32", "");
|
||||
::Swagger::setValue(&_return, pJson["return"], "qint32", "");
|
||||
}
|
||||
|
||||
QString
|
||||
@ -73,18 +73,18 @@ QJsonObject*
|
||||
SWGReturn::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
|
||||
obj->insert("return", QJsonValue(return));
|
||||
obj->insert("return", QJsonValue(_return));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qint32
|
||||
SWGReturn::getReturn() {
|
||||
return return;
|
||||
return _return;
|
||||
}
|
||||
void
|
||||
SWGReturn::setReturn(qint32 return) {
|
||||
this->return = return;
|
||||
SWGReturn::setReturn(qint32 _return) {
|
||||
this->_return = _return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,11 +42,11 @@ public:
|
||||
SWGReturn* fromJson(QString &jsonString);
|
||||
|
||||
qint32 getReturn();
|
||||
void setReturn(qint32 return);
|
||||
void setReturn(qint32 _return);
|
||||
|
||||
|
||||
private:
|
||||
qint32 return;
|
||||
qint32 _return;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
@ -122,7 +123,9 @@ module Petstore
|
||||
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
|
||||
|
||||
# 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]"
|
||||
def deserialize(response, return_type)
|
||||
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 response body directly for String return type
|
||||
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
|
||||
content_type = response.headers['Content-Type'] || 'application/json'
|
||||
|
||||
@ -213,10 +218,15 @@ module Petstore
|
||||
|
||||
# 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.
|
||||
# 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
|
||||
# @return [Tempfile] the file downloaded
|
||||
def download_file(response)
|
||||
def download_file(request)
|
||||
tempfile = nil
|
||||
encoding = nil
|
||||
request.on_headers do |response|
|
||||
content_disposition = response.headers['Content-Disposition']
|
||||
if content_disposition and content_disposition =~ /filename=/i
|
||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||
@ -225,18 +235,21 @@ module Petstore
|
||||
prefix = 'download-'
|
||||
end
|
||||
prefix = prefix + '-' unless prefix.end_with?('-')
|
||||
|
||||
tempfile = nil
|
||||
encoding = response.body.encoding
|
||||
Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
|
||||
file.write(response.body)
|
||||
tempfile = file
|
||||
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`"
|
||||
tempfile
|
||||
end
|
||||
end
|
||||
|
||||
# Sanitize filename by removing path.
|
||||
@ -267,7 +280,7 @@ module Petstore
|
||||
data = {}
|
||||
form_params.each do |key, value|
|
||||
case value
|
||||
when File, Array, nil
|
||||
when ::File, ::Array, nil
|
||||
# let typhoeus handle File, Array and nil parameters
|
||||
data[key] = value
|
||||
else
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
@ -75,6 +76,11 @@ module Petstore
|
||||
# Default to 0 (never times out).
|
||||
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
|
||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||
# Default to true.
|
||||
@ -128,6 +134,7 @@ module Petstore
|
||||
@api_key = {}
|
||||
@api_key_prefix = {}
|
||||
@timeout = 0
|
||||
@client_side_validation = true
|
||||
@verify_ssl = true
|
||||
@verify_ssl_host = true
|
||||
@params_encoding = nil
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
Swagger Codegen version: 2.3.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
@ -28,15 +29,15 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.9"
|
||||
|
||||
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 'webmock', '~> 1.24', '>= 1.24.3'
|
||||
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-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.test_files = `find spec/*`.split("\n")
|
||||
|
@ -153,7 +153,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-scala_2.10</artifactId>
|
||||
<artifactId>jackson-module-scala_2.11</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -189,7 +189,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.10</artifactId>
|
||||
<artifactId>scalatest_2.11</artifactId>
|
||||
<version>${scala-test-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@ -211,16 +211,16 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<scala-version>2.10.4</scala-version>
|
||||
<scala-version>2.11.11</scala-version>
|
||||
<joda-version>1.2</joda-version>
|
||||
<joda-time-version>2.2</joda-time-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>
|
||||
<maven-plugin.version>1.0.0</maven-plugin.version>
|
||||
<jackson-version>2.8.9</jackson-version>
|
||||
|
@ -28,7 +28,7 @@ import java.util.UUID
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.collection.mutable
|
||||
|
||||
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule
|
||||
@ -41,8 +41,8 @@ object ScalaJsonUtil {
|
||||
def getJsonMapper = {
|
||||
val mapper = new ObjectMapper()
|
||||
mapper.registerModule(new DefaultScalaModule())
|
||||
mapper.registerModule(new JodaModule());
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.registerModule(new JodaModule())
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
@ -52,13 +52,14 @@ object ScalaJsonUtil {
|
||||
}
|
||||
|
||||
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders: HashMap[String, String] = HashMap(),
|
||||
hostMap: HashMap[String, Client] = HashMap(),
|
||||
httpHeaders: mutable.HashMap[String, String] = mutable.HashMap(),
|
||||
hostMap: mutable.HashMap[String, Client] = mutable.HashMap(),
|
||||
asyncHttpClient: Boolean = false,
|
||||
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 = {
|
||||
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: Double): String = value.toString
|
||||
|
||||
def escape(value: Float): String = value.toString
|
||||
|
||||
def escape(value: UUID): String = value.toString
|
||||
|
||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||
@ -89,16 +87,16 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
} else {
|
||||
containerType.toLowerCase match {
|
||||
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[_]]
|
||||
response.asScala.toList
|
||||
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[_]]
|
||||
response.asScala.toList
|
||||
case _ =>
|
||||
json match {
|
||||
case e: String if ("\"\"" == e) => null
|
||||
case e: String if "\"\"" == e => null
|
||||
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 _ => 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 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)
|
||||
headerParams.map(p => builder.header(p._1, p._2))
|
||||
defaultHeaders.map(p => {
|
||||
defaultHeaders.foreach(p => {
|
||||
headerParams.contains(p._1) match {
|
||||
case true => // override default with supplied header
|
||||
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
|
||||
if (contentType == "application/x-www-form-urlencoded") {
|
||||
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 {
|
||||
case "GET" => builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
|
||||
case "POST" =>
|
||||
if (formData != null) {
|
||||
if (formData != null && formData.size() > 0) {
|
||||
builder.post(classOf[ClientResponse], formData)
|
||||
} else if (body != null && body.isInstanceOf[File]) {
|
||||
val file = body.asInstanceOf[File]
|
||||
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))
|
||||
builder.post(classOf[ClientResponse], form)
|
||||
} else {
|
||||
@ -151,11 +160,15 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
}
|
||||
}
|
||||
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))
|
||||
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" => {
|
||||
case "PATCH" =>
|
||||
if(formData != null) {
|
||||
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], formData)
|
||||
} else if(body == null) {
|
||||
@ -163,24 +176,21 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
} else {
|
||||
builder.header("X-HTTP-Method-Override", "PATCH").`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getStatusInfo().getStatusCode() match {
|
||||
response.getStatusInfo.getStatusCode match {
|
||||
case 204 => ""
|
||||
case code: Int if (Range(200, 299).contains(code)) =>
|
||||
response.hasEntity() match {
|
||||
case code: Int if Range(200, 299).contains(code) =>
|
||||
response.hasEntity match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => ""
|
||||
}
|
||||
case _ =>
|
||||
val entity = response.hasEntity() match {
|
||||
val entity = response.hasEntity match {
|
||||
case true => response.getEntity(classOf[String])
|
||||
case false => "no data"
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getStatusInfo().getStatusCode(),
|
||||
entity)
|
||||
throw new ApiException(response.getStatusInfo.getStatusCode, entity)
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +214,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||
if (!authScheme.isEmpty) {
|
||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||
config.getAsyncHttpClientConfigBuilder
|
||||
config
|
||||
.getAsyncHttpClientConfigBuilder
|
||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||
.setUsePreemptiveAuth(authPreemptive).build)
|
||||
}
|
||||
@ -215,8 +226,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
|
||||
object ApiInvoker extends ApiInvoker(
|
||||
mapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders = HashMap(),
|
||||
hostMap = HashMap(),
|
||||
httpHeaders = mutable.HashMap(),
|
||||
hostMap = mutable.HashMap(),
|
||||
asyncHttpClient = false,
|
||||
authScheme = "",
|
||||
authPreemptive = false
|
||||
|
@ -40,8 +40,10 @@ import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
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",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker) {
|
||||
class FakeApi(
|
||||
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 {
|
||||
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 jsonWriter = JsonFormatsWriter
|
||||
|
||||
var basePath = defBasePath
|
||||
var apiInvoker = defApiInvoker
|
||||
var basePath: String = defBasePath
|
||||
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 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)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class FakeApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
|
@ -1 +1 @@
|
||||
2.2.3
|
||||
2.3.0-SNAPSHOT
|
@ -1,7 +1,21 @@
|
||||
import * as api from './api/api';
|
||||
import * as angular from 'angular';
|
||||
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { Configuration } from './configuration';
|
||||
|
||||
const apiModule = angular.module('api', [])
|
||||
.service('FakeApi', api.FakeApi)
|
||||
import { FakeService } from './api/fake.service';
|
||||
|
||||
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';
|
||||
import { FakeApi } from './FakeApi';
|
||||
export const APIS = [FakeApi];
|
||||
export * from './fake.service';
|
||||
import { FakeService } from './fake.service';
|
||||
export const APIS = [FakeService];
|
||||
|
@ -1,2 +1,5 @@
|
||||
export * from './api/api';
|
||||
export * from './model/models';
|
||||
export * from './variables';
|
||||
export * from './configuration';
|
||||
export * from './api.module';
|
@ -10,7 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import * as models from './models';
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
@ -19,6 +19,8 @@ export interface ModelReturn {
|
||||
/**
|
||||
* 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 ]
|
||||
})
|
||||
export class ApiModule {
|
||||
public static forConfig(configuration: Configuration): ModuleWithProviders {
|
||||
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ {provide: Configuration, useValue: configuration}]
|
||||
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Http, Headers, URLSearchParams } from '@angular/http';
|
||||
import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http';
|
||||
import { Response, ResponseContentType } from '@angular/http';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import '../rxjs-operators';
|
||||
@ -21,17 +21,17 @@ import '../rxjs-operators';
|
||||
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
import { CustomHttpUrlEncodingCodec } from '../encoder';
|
||||
|
||||
|
||||
@Injectable()
|
||||
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) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -41,21 +41,6 @@ export class FakeService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
* @return true: consumes contains 'multipart/form-data', false: otherwise
|
||||
@ -70,21 +55,6 @@ export class FakeService {
|
||||
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
|
||||
*/
|
||||
public testCodeInjectEndRnNRWithHttpInfo(test code inject * ' " =end rn n r?: string, extraHttpRequestParams?: any): Observable<Response> {
|
||||
const path = this.basePath + '/fake';
|
||||
public testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string): Observable<{}> {
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
let headers = this.defaultHeaders;
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
'*_/ =end -- '
|
||||
];
|
||||
let canConsumeForm = this.canConsumeForm(consumes);
|
||||
let useForm = false;
|
||||
let formParams = new (useForm ? FormData : URLSearchParams as any)() as {
|
||||
set(param: string, value: any): void;
|
||||
};
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
let useForm = false;
|
||||
let convertFormParamsToString = false;
|
||||
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) {
|
||||
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({
|
||||
method: RequestMethod.Put,
|
||||
return this.httpClient.put<any>(`${this.basePath}/fake`,
|
||||
convertFormParamsToString ? formParams.toString() : formParams, {
|
||||
headers: headers,
|
||||
body: formParams.toString(),
|
||||
search: queryParameters,
|
||||
withCredentials:this.configuration.withCredentials
|
||||
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};
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string;
|
||||
accessToken?: string | (() => string);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
apiKeys: {[ key: string ]: string};
|
||||
username: string;
|
||||
password: string;
|
||||
accessToken: string | (() => string);
|
||||
basePath: string;
|
||||
withCredentials: boolean;
|
||||
apiKeys?: {[ key: string ]: string};
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | (() => string);
|
||||
basePath?: string;
|
||||
withCredentials?: boolean;
|
||||
|
||||
constructor(configurationParameters: ConfigurationParameters = {}) {
|
||||
this.apiKeys = configurationParameters.apiKeys;
|
||||
|
@ -22,3 +22,5 @@ export interface ModelReturn {
|
||||
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 COLLECTION_FORMATS = {
|
||||
|
@ -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 COLLECTION_FORMATS = {
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
@ -102,26 +106,28 @@ export const FakeApiFetchParamCreator = function (configuration?: Configuration)
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string, options: any = {}): FetchArgs {
|
||||
const path = `/fake`;
|
||||
const urlObj = url.parse(path, true);
|
||||
const requestOptions = Object.assign({ method: 'PUT' }, options);
|
||||
const headerParameter = {} as any;
|
||||
const queryParameter = {} as any;
|
||||
const formParams = new url.URLSearchParams();
|
||||
const localVarPath = `/fake`;
|
||||
const localVarUrlObj = url.parse(localVarPath, true);
|
||||
const localVarRequestOptions = Object.assign({ method: 'PUT' }, options);
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
const localVarFormParams = new url.URLSearchParams();
|
||||
|
||||
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);
|
||||
requestOptions.headers = Object.assign({}, headerParameter, options.headers);
|
||||
requestOptions.body = formParams.toString();
|
||||
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
|
||||
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
|
||||
delete localVarUrlObj.search;
|
||||
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
|
||||
localVarRequestOptions.body = localVarFormParams.toString();
|
||||
|
||||
return {
|
||||
url: url.format(urlObj),
|
||||
options: requestOptions,
|
||||
url: url.format(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
}
|
||||
@ -141,9 +147,9 @@ export const FakeApiFp = function(configuration?: Configuration) {
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
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(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
|
||||
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response;
|
||||
} else {
|
||||
|
@ -269,8 +269,8 @@ export class FakeApi {
|
||||
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
|
||||
*/
|
||||
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 useFormData = false;
|
||||
|
||||
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) {
|
||||
$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 ?');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user