Skip to content

Commit 21777f2

Browse files
ackintoshwing328
authored andcommitted
[JavaScript] Update vulnerable dependencies (#784)
* Update vulnerable dependencies * Update samples: javascript-es6 * Update samples: javascript-promise * Update samples: javascript-promise-es6 * Update samples: javascript * Update samples: petstore-security-test/javascript * Rename operationId if it starts with a number * Update samples bin/javascript-petstore.sh bin/javascript-es6-petstore.sh bin/javascript-promise-petstore.sh bin/javascript-promise-es6-petstore.sh
1 parent afdef8f commit 21777f2

171 files changed

Lines changed: 3065 additions & 255 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,13 @@ public String toOperationId(String operationId) {
837837
return newOperationId;
838838
}
839839

840+
// operationId starts with a number
841+
if (operationId.matches("^\\d.*")) {
842+
String newOperationId = camelize("call_" + operationId, true);
843+
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + newOperationId);
844+
return newOperationId;
845+
}
846+
840847
return operationId;
841848
}
842849

modules/openapi-generator/src/main/resources/Javascript/es6/package.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"babel": "^6.23.0",
1515
"babel-cli": "^6.26.0",
16-
"superagent": "3.5.2"
16+
"superagent": "3.7.0"
1717
},
1818
"devDependencies": {
1919
"babel-core": "6.26.0",

modules/openapi-generator/src/main/resources/Javascript/package.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"fs": false
1212
},
1313
"dependencies": {
14-
"superagent": "3.5.2"
14+
"superagent": "3.7.0"
1515
},
1616
"devDependencies": {
1717
"mocha": "~2.3.4",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.0-SNAPSHOT
1+
3.2.0-SNAPSHOT

samples/client/petstore-security-test/javascript/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# swagger_petstore____end____rn_n_r
1+
# open_api_petstore____end____rn_n_r
22

3-
SwaggerPetstoreEndRnNR - JavaScript client for swagger_petstore____end____rn_n_r
3+
OpenApiPetstoreEndRnNR - JavaScript client for open_api_petstore____end____rn_n_r
44
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 --
5-
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
5+
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
66

77
- API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
88
- Package version: 1.0.0 *_/ =end -- \r\n \n \r
9-
- Build package: io.swagger.codegen.languages.JavascriptClientCodegen
9+
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
1010

1111
## Installation
1212

@@ -20,7 +20,7 @@ please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.co
2020
Then install it via:
2121

2222
```shell
23-
npm install swagger_petstore____end____rn_n_r --save
23+
npm install open_api_petstore____end____rn_n_r --save
2424
```
2525

2626
##### Local development
@@ -38,13 +38,13 @@ Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the follow
3838
npm link
3939
```
4040

41-
Finally, switch to the directory you want to use your swagger_petstore____end____rn_n_r from, and run:
41+
Finally, switch to the directory you want to use your open_api_petstore____end____rn_n_r from, and run:
4242

4343
```shell
4444
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
4545
```
4646

47-
You should now be able to `require('swagger_petstore____end____rn_n_r')` in javascript files from the directory you ran the last
47+
You should now be able to `require('open_api_petstore____end____rn_n_r')` in javascript files from the directory you ran the last
4848
command above from.
4949

5050
#### git
@@ -93,12 +93,11 @@ module: {
9393
Please follow the [installation](#installation) instruction and execute the following JS code:
9494

9595
```javascript
96-
var SwaggerPetstoreEndRnNR = require('swagger_petstore____end____rn_n_r');
96+
var OpenApiPetstoreEndRnNR = require('open_api_petstore____end____rn_n_r');
9797

98-
var api = new SwaggerPetstoreEndRnNR.FakeApi()
99-
100-
var opts = {
101-
'testCodeInjectEndRnNR': "testCodeInjectEndRnNR_example" // {String} To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
98+
var api = new OpenApiPetstoreEndRnNR.FakeApi()
99+
var opts = {
100+
'UNKNOWN_BASE_TYPE': new OpenApiPetstoreEndRnNR.UNKNOWN_BASE_TYPE() // {UNKNOWN_BASE_TYPE}
102101
};
103102

104103
var callback = function(error, data, response) {
@@ -114,16 +113,16 @@ api.testCodeInjectEndRnNR(opts, callback);
114113

115114
## Documentation for API Endpoints
116115

117-
All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
116+
All URIs are relative to *http://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
118117

119118
Class | Method | HTTP request | Description
120119
------------ | ------------- | ------------- | -------------
121-
*SwaggerPetstoreEndRnNR.FakeApi* | [**testCodeInjectEndRnNR**](docs/FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
120+
*OpenApiPetstoreEndRnNR.FakeApi* | [**testCodeInjectEndRnNR**](docs/FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
122121

123122

124123
## Documentation for Models
125124

126-
- [SwaggerPetstoreEndRnNR.ModelReturn](docs/ModelReturn.md)
125+
- [OpenApiPetstoreEndRnNR.ModelReturn](docs/ModelReturn.md)
127126

128127

129128
## Documentation for Authorization

samples/client/petstore-security-test/javascript/docs/FakeApi.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# SwaggerPetstoreEndRnNR.FakeApi
1+
# OpenApiPetstoreEndRnNR.FakeApi
22

3-
All URIs are relative to *https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
3+
All URIs are relative to *http://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
@@ -13,16 +13,16 @@ Method | HTTP request | Description
1313
1414
To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
1515

16+
To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
17+
1618
### Example
1719
```javascript
18-
var SwaggerPetstoreEndRnNR = require('swagger_petstore____end____rn_n_r');
20+
var OpenApiPetstoreEndRnNR = require('open_api_petstore____end____rn_n_r');
1921

20-
var apiInstance = new SwaggerPetstoreEndRnNR.FakeApi();
21-
22-
var opts = {
23-
'testCodeInjectEndRnNR': "testCodeInjectEndRnNR_example" // String | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
22+
var apiInstance = new OpenApiPetstoreEndRnNR.FakeApi();
23+
var opts = {
24+
'UNKNOWN_BASE_TYPE': new OpenApiPetstoreEndRnNR.UNKNOWN_BASE_TYPE() // UNKNOWN_BASE_TYPE |
2425
};
25-
2626
var callback = function(error, data, response) {
2727
if (error) {
2828
console.error(error);
@@ -37,7 +37,7 @@ apiInstance.testCodeInjectEndRnNR(opts, callback);
3737

3838
Name | Type | Description | Notes
3939
------------- | ------------- | ------------- | -------------
40-
**testCodeInjectEndRnNR** | **String**| To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
40+
**UNKNOWN_BASE_TYPE** | [**UNKNOWN_BASE_TYPE**](UNKNOWN_BASE_TYPE.md)| | [optional]
4141

4242
### Return type
4343

@@ -50,5 +50,5 @@ No authorization required
5050
### HTTP request headers
5151

5252
- **Content-Type**: application/json, *_/ =end --
53-
- **Accept**: application/json, *_/ =end --
53+
- **Accept**: Not defined
5454

samples/client/petstore-security-test/javascript/docs/ModelReturn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SwaggerPetstoreEndRnNR.ModelReturn
1+
# OpenApiPetstoreEndRnNR.ModelReturn
22

33
## Properties
44
Name | Type | Description | Notes

samples/client/petstore-security-test/javascript/git_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
33
#
4-
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
4+
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
55

66
git_user_id=$1
77
git_repo_id=$2

samples/client/petstore-security-test/javascript/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "swagger_petstore____end____rn_n_r",
2+
"name": "open_api_petstore____end____rn_n_r",
33
"version": "1.0.0 *_/ =end -- \r\n \n \r",
44
"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______",
55
"license": "Apache-2.0 */ &#39; &quot; &#x3D;end -- \r\n \n \r",
@@ -11,7 +11,7 @@
1111
"fs": false
1212
},
1313
"dependencies": {
14-
"superagent": "3.5.2"
14+
"superagent": "3.7.0"
1515
},
1616
"devDependencies": {
1717
"mocha": "~2.3.4",

samples/client/petstore-security-test/javascript/src/ApiClient.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
2-
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
2+
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
33
* 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 --
44
*
55
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
6-
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
6+
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
77
*
8-
* NOTE: This class is auto generated by the swagger code generator program.
9-
* https://github.com/swagger-api/swagger-codegen.git
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
1010
*
11-
* Swagger Codegen version: 2.3.0-SNAPSHOT
11+
* OpenAPI Generator version: 3.2.0-SNAPSHOT
1212
*
1313
* Do not edit the class manually.
1414
*
@@ -23,10 +23,10 @@
2323
module.exports = factory(require('superagent'), require('querystring'));
2424
} else {
2525
// Browser globals (root is window)
26-
if (!root.SwaggerPetstoreEndRnNR) {
27-
root.SwaggerPetstoreEndRnNR = {};
26+
if (!root.OpenApiPetstoreEndRnNR) {
27+
root.OpenApiPetstoreEndRnNR = {};
2828
}
29-
root.SwaggerPetstoreEndRnNR.ApiClient = factory(root.superagent, root.querystring);
29+
root.OpenApiPetstoreEndRnNR.ApiClient = factory(root.superagent, root.querystring);
3030
}
3131
}(this, function(superagent, querystring) {
3232
'use strict';
@@ -47,9 +47,9 @@
4747
/**
4848
* The base URL against which to resolve every API call's (relative) path.
4949
* @type {String}
50-
* @default https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r
50+
* @default http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r
5151
*/
52-
this.basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'.replace(/\/+$/, '');
52+
this.basePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r'.replace(/\/+$/, '');
5353

5454
/**
5555
* The authentication methods to be included for all API calls.
@@ -96,6 +96,10 @@
9696
this.agent = new superagent.agent();
9797
}
9898

99+
/*
100+
* Allow user to override superagent agent
101+
*/
102+
this.requestAgent = null;
99103
};
100104

101105
/**
@@ -413,6 +417,12 @@
413417
// set header parameters
414418
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
415419

420+
421+
// set requestAgent if it is set by user
422+
if (this.requestAgent) {
423+
request.agent(this.requestAgent);
424+
}
425+
416426
// set request timeout
417427
request.timeout(this.timeout);
418428

0 commit comments

Comments
 (0)