Bugfix/3929 do not set multipart (#3932)

* Do not set Content-Type to multipart/form-data
It causes superagent to not add the boundary in the Content-Type

* Run shell-scripts
This commit is contained in:
Andreas Franzén 2016-10-08 06:36:56 +02:00 committed by wing328
parent 04070b32c1
commit d21613c6ab
12 changed files with 106 additions and 94 deletions

View File

@ -363,7 +363,10 @@
var contentType = this.jsonPreferredMime(contentTypes);
if (contentType) {
request.type(contentType);
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
if(contentType != 'multipart/form-data') {
request.type(contentType);
}
} else if (!request.header['Content-Type']) {
request.type('application/json');
}

View File

@ -1,12 +1,11 @@
# swagger_petstore____end
# swagger_petstore____end____rn_n_r
SwaggerPetstoreEnd - JavaScript client for swagger_petstore____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
SwaggerPetstoreEndRnNR - JavaScript client for swagger_petstore____end____rn_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 SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 ' \" =end
- Package version: 1.0.0 =end
- Build date: 2016-06-29T21:40:05.384+08:00
- API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
- Package version: 1.0.0 *_/ =end -- \r\n \n \r
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen
## Installation
@ -21,7 +20,7 @@ please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.co
Then install it via:
```shell
npm install swagger_petstore____end --save
npm install swagger_petstore____end____rn_n_r --save
```
#### git
@ -51,12 +50,12 @@ Then include *bundle.js* in the HTML pages.
Please follow the [installation](#installation) instruction and execute the following JS code:
```javascript
var SwaggerPetstoreEnd = require('swagger_petstore____end');
var SwaggerPetstoreEndRnNR = require('swagger_petstore____end____rn_n_r');
var api = new SwaggerPetstoreEnd.FakeApi()
var api = new SwaggerPetstoreEndRnNR.FakeApi()
var opts = {
'testCodeInjectEnd': "testCodeInjectEnd_example" // {String} To test code injection ' \" =end
'testCodeInjectEndRnNR': "testCodeInjectEndRnNR_example" // {String} To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
};
var callback = function(error, data, response) {
@ -66,22 +65,22 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
api.testCodeInjectEnd(opts, callback);
api.testCodeInjectEndRnNR(opts, callback);
```
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*SwaggerPetstoreEnd.FakeApi* | [**testCodeInjectEnd**](docs/FakeApi.md#testCodeInjectEnd) | **PUT** /fake | To test code injection ' \" =end
*SwaggerPetstoreEndRnNR.FakeApi* | [**testCodeInjectEndRnNR**](docs/FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
## Documentation for Models
- [SwaggerPetstoreEnd.ModelReturn](docs/ModelReturn.md)
- [SwaggerPetstoreEndRnNR.ModelReturn](docs/ModelReturn.md)
## Documentation for Authorization
@ -90,7 +89,7 @@ Class | Method | HTTP request | Description
### api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
- **Location**: HTTP header
### petstore_auth
@ -99,6 +98,6 @@ Class | Method | HTTP request | Description
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account */ ' " =end
- read:pets: read your pets */ ' " =end
- write:pets: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r
- read:pets: read your pets *_/ ' \" =end -- \\r\\n \\n \\r

View File

@ -1,26 +1,26 @@
# SwaggerPetstoreEnd.FakeApi
# SwaggerPetstoreEndRnNR.FakeApi
All URIs are relative to *https://petstore.swagger.io ' \" =end/v2 ' \" =end*
All URIs are relative to *https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testCodeInjectEnd**](FakeApi.md#testCodeInjectEnd) | **PUT** /fake | To test code injection ' \" =end
[**testCodeInjectEndRnNR**](FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
<a name="testCodeInjectEnd"></a>
# **testCodeInjectEnd**
> testCodeInjectEnd(opts)
<a name="testCodeInjectEndRnNR"></a>
# **testCodeInjectEndRnNR**
> testCodeInjectEndRnNR(opts)
To test code injection &#39; \&quot; &#x3D;end
To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
### Example
```javascript
var SwaggerPetstoreEnd = require('swagger_petstore____end');
var SwaggerPetstoreEndRnNR = require('swagger_petstore____end____rn_n_r');
var apiInstance = new SwaggerPetstoreEnd.FakeApi();
var apiInstance = new SwaggerPetstoreEndRnNR.FakeApi();
var opts = {
'testCodeInjectEnd': "testCodeInjectEnd_example" // String | To test code injection ' \" =end
'testCodeInjectEndRnNR': "testCodeInjectEndRnNR_example" // String | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
};
var callback = function(error, data, response) {
@ -30,14 +30,14 @@ var callback = function(error, data, response) {
console.log('API called successfully.');
}
};
apiInstance.testCodeInjectEnd(opts, callback);
apiInstance.testCodeInjectEndRnNR(opts, callback);
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**testCodeInjectEnd** | **String**| To test code injection &#39; \&quot; &#x3D;end | [optional]
**testCodeInjectEndRnNR** | **String**| To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
### Return type
@ -49,6 +49,6 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ =end
- **Accept**: application/json, */ =end
- **Content-Type**: application/json, *_/ =end --
- **Accept**: application/json, *_/ =end --

View File

@ -1,8 +1,8 @@
# SwaggerPetstoreEnd.ModelReturn
# SwaggerPetstoreEndRnNR.ModelReturn
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_return** | **Integer** | property description &#39; \&quot; &#x3D;end | [optional]
**_return** | **Number** | property description *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]

View File

@ -1,7 +1,7 @@
{
"name": "swagger_petstore____end",
"version": "1.0.0 =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",
"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": "Apache-2.0",
"main": "src/index.js",
"scripts": {

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore ' \" =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
* 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 --
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -31,17 +31,17 @@
module.exports = factory(require('superagent'));
} else {
// Browser globals (root is window)
if (!root.SwaggerPetstoreEnd) {
root.SwaggerPetstoreEnd = {};
if (!root.SwaggerPetstoreEndRnNR) {
root.SwaggerPetstoreEndRnNR = {};
}
root.SwaggerPetstoreEnd.ApiClient = factory(root.superagent);
root.SwaggerPetstoreEndRnNR.ApiClient = factory(root.superagent);
}
}(this, function(superagent) {
'use strict';
/**
* @module ApiClient
* @version 1.0.0 &#x3D;end
* @version 1.0.0 *_/ &#x3D;end -- \r\n \n \r
*/
/**
@ -55,16 +55,16 @@
/**
* The base URL against which to resolve every API call's (relative) path.
* @type {String}
* @default https://petstore.swagger.io &#39; \&quot; &#x3D;end/v2 &#39; \&quot; &#x3D;end
* @default https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
*/
this.basePath = 'https://petstore.swagger.io &#39; \&quot; &#x3D;end/v2 &#39; \&quot; &#x3D;end'.replace(/\/+$/, '');
this.basePath = 'https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r'.replace(/\/+$/, '');
/**
* The authentication methods to be included for all API calls.
* @type {Array.<String>}
*/
this.authentications = {
'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key */ &#39; &quot; &#x3D;end'},
'api_key': {type: 'apiKey', 'in': 'header', name: 'api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r'},
'petstore_auth': {type: 'oauth2'}
};
/**
@ -154,7 +154,7 @@
/**
* Checks whether the given parameter value represents file-like content.
* @param param The parameter to check.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
*/
exports.prototype.isFileParam = function(param) {
// fs.ReadStream in Node.js (but not in runtime like browserify)
@ -206,7 +206,7 @@
/**
* Enumeration of collection format separator strategies.
* @enum {String}
* @enum {String}
* @readonly
*/
exports.CollectionFormatEnum = {
@ -376,7 +376,10 @@
var contentType = this.jsonPreferredMime(contentTypes);
if (contentType) {
request.type(contentType);
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
if(contentType != 'multipart/form-data') {
request.type(contentType);
}
} else if (!request.header['Content-Type']) {
request.type('application/json');
}

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore ' \" =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
* 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 --
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -31,10 +31,10 @@
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerPetstoreEnd) {
root.SwaggerPetstoreEnd = {};
if (!root.SwaggerPetstoreEndRnNR) {
root.SwaggerPetstoreEndRnNR = {};
}
root.SwaggerPetstoreEnd.FakeApi = factory(root.SwaggerPetstoreEnd.ApiClient);
root.SwaggerPetstoreEndRnNR.FakeApi = factory(root.SwaggerPetstoreEndRnNR.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
@ -42,7 +42,7 @@
/**
* Fake service.
* @module api/FakeApi
* @version 1.0.0 &#x3D;end
* @version 1.0.0 *_/ &#x3D;end -- \r\n \n \r
*/
/**
@ -57,20 +57,20 @@
/**
* Callback function to receive the result of the testCodeInjectEnd operation.
* @callback module:api/FakeApi~testCodeInjectEndCallback
* Callback function to receive the result of the testCodeInjectEndRnNR operation.
* @callback module:api/FakeApi~testCodeInjectEndRnNRCallback
* @param {String} error Error message, if any.
* @param data This operation does not return a value.
* @param {String} response The complete HTTP response.
*/
/**
* To test code injection &#39; \&quot; &#x3D;end
* To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param {Object} opts Optional parameters
* @param {String} opts.testCodeInjectEnd To test code injection &#39; \&quot; &#x3D;end
* @param {module:api/FakeApi~testCodeInjectEndCallback} callback The callback function, accepting three arguments: error, data, response
* @param {String} opts.testCodeInjectEndRnNR To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @param {module:api/FakeApi~testCodeInjectEndRnNRCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.testCodeInjectEnd = function(opts, callback) {
this.testCodeInjectEndRnNR = function(opts, callback) {
opts = opts || {};
var postBody = null;
@ -82,12 +82,12 @@
var headerParams = {
};
var formParams = {
'test code inject */ &#39; &quot; &#x3D;end': opts['testCodeInjectEnd']
'test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r': opts['testCodeInjectEndRnNR']
};
var authNames = [];
var contentTypes = ['application/json', '*/ =end'];
var accepts = ['application/json', '*/ =end'];
var contentTypes = ['application/json', '*_/ =end -- '];
var accepts = ['application/json', '*_/ =end -- '];
var returnType = null;
return this.apiClient.callApi(

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore ' \" =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
* 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 --
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -34,14 +34,14 @@
'use strict';
/**
* 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.<br>
* 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______.<br>
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
* <p>
* An AMD (recommended!) or CommonJS application will generally do something equivalent to the following:
* <pre>
* var SwaggerPetstoreEnd = require('index'); // See note below*.
* var xxxSvc = new SwaggerPetstoreEnd.XxxApi(); // Allocate the API class we're going to use.
* var yyyModel = new SwaggerPetstoreEnd.Yyy(); // Construct a model instance.
* var SwaggerPetstoreEndRnNR = require('index'); // See note below*.
* var xxxSvc = new SwaggerPetstoreEndRnNR.XxxApi(); // Allocate the API class we're going to use.
* var yyyModel = new SwaggerPetstoreEndRnNR.Yyy(); // Construct a model instance.
* yyyModel.someProperty = 'someValue';
* ...
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
@ -53,8 +53,8 @@
* <p>
* A non-AMD browser application (discouraged) might do something like this:
* <pre>
* var xxxSvc = new SwaggerPetstoreEnd.XxxApi(); // Allocate the API class we're going to use.
* var yyy = new SwaggerPetstoreEnd.Yyy(); // Construct a model instance.
* var xxxSvc = new SwaggerPetstoreEndRnNR.XxxApi(); // Allocate the API class we're going to use.
* var yyy = new SwaggerPetstoreEndRnNR.Yyy(); // Construct a model instance.
* yyyModel.someProperty = 'someValue';
* ...
* var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
@ -62,7 +62,7 @@
* </pre>
* </p>
* @module index
* @version 1.0.0 &#x3D;end
* @version 1.0.0 *_/ &#x3D;end -- \r\n \n \r
*/
var exports = {
/**

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore ' \" =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
* 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 --
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -31,10 +31,10 @@
module.exports = factory(require('../ApiClient'));
} else {
// Browser globals (root is window)
if (!root.SwaggerPetstoreEnd) {
root.SwaggerPetstoreEnd = {};
if (!root.SwaggerPetstoreEndRnNR) {
root.SwaggerPetstoreEndRnNR = {};
}
root.SwaggerPetstoreEnd.ModelReturn = factory(root.SwaggerPetstoreEnd.ApiClient);
root.SwaggerPetstoreEndRnNR.ModelReturn = factory(root.SwaggerPetstoreEndRnNR.ApiClient);
}
}(this, function(ApiClient) {
'use strict';
@ -45,12 +45,12 @@
/**
* The ModelReturn model module.
* @module model/ModelReturn
* @version 1.0.0 &#x3D;end
* @version 1.0.0 *_/ &#x3D;end -- \r\n \n \r
*/
/**
* Constructs a new <code>ModelReturn</code>.
* Model for testing reserved words &#39; \&quot; &#x3D;end
* Model for testing reserved words *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
* @alias module:model/ModelReturn
* @class
*/
@ -72,15 +72,15 @@
obj = obj || new exports();
if (data.hasOwnProperty('return')) {
obj['return'] = ApiClient.convertToType(data['return'], 'Integer');
obj['return'] = ApiClient.convertToType(data['return'], 'Number');
}
}
return obj;
}
/**
* property description ' \" =end
* @member {Integer} return
* property description *_/ ' \" =end -- \\r\\n \\n \\r
* @member {Number} return
*/
exports.prototype['return'] = undefined;

View File

@ -90,7 +90,8 @@ var opts = {
'binary': "B", // String | None
'_date': new Date("2013-10-20"), // Date | None
'dateTime': new Date("2013-10-20T19:20:30+01:00"), // Date | None
'password': "password_example" // String | None
'password': "password_example", // String | None
'callback': "callback_example" // String | None
};
var callback = function(error, data, response) {
@ -120,6 +121,7 @@ Name | Type | Description | Notes
**_date** | **Date**| None | [optional]
**dateTime** | **Date**| None | [optional]
**password** | **String**| None | [optional]
**callback** | **String**| None | [optional]
### Return type

View File

@ -377,7 +377,10 @@
var contentType = this.jsonPreferredMime(contentTypes);
if (contentType) {
request.type(contentType);
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
if(contentType != 'multipart/form-data') {
request.type(contentType);
}
} else if (!request.header['Content-Type']) {
request.type('application/json');
}

View File

@ -125,6 +125,7 @@
* @param {Date} opts._date None
* @param {Date} opts.dateTime None
* @param {String} opts.password None
* @param {String} opts.callback None
* @param {module:api/FakeApi~testEndpointParametersCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.testEndpointParameters = function(_number, _double, patternWithoutDelimiter, _byte, opts, callback) {
@ -171,7 +172,8 @@
'binary': opts['binary'],
'date': opts['_date'],
'dateTime': opts['dateTime'],
'password': opts['password']
'password': opts['password'],
'callback': opts['callback']
};
var authNames = ['http_basic_test'];