Update security samples for Scala + typescript-node. (#5325)

This commit is contained in:
Paŭlo Ebermann
2017-04-05 12:05:21 +02:00
committed by wing328
parent be83329946
commit 0c1ad9b2ba
2 changed files with 31 additions and 41 deletions

View File

@@ -103,10 +103,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>

View File

@@ -1,32 +1,20 @@
/**
* 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
* 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 \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import request = require('request');
import http = require('http');
import Promise = require('bluebird');
let defaultBasePath = 'https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r/v2 *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r';
let defaultBasePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
// ===============================================
// This file is autogenerated - Please do not edit
@@ -35,11 +23,11 @@ let defaultBasePath = 'https://petstore.swagger.io *_/ &#39; \&quot; &#x3D;end \
/* tslint:disable:no-unused-variable */
/**
* Model for testing reserved words *_/ ' \" =end \\r\\n \\n \\r
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
*/
export class ModelReturn {
/**
* property description *_/ ' \" =end \\r\\n \\n \\r
* property description *_/ ' \" =end -- \\r\\n \\n \\r
*/
'return': number;
}
@@ -71,7 +59,7 @@ export class ApiKeyAuth implements Authentication {
applyToRequest(requestOptions: request.Options): void {
if (this.location == "query") {
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
} else if (this.location == "header") {
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
requestOptions.headers[this.paramName] = this.apiKey;
}
}
@@ -81,14 +69,16 @@ export class OAuth implements Authentication {
public accessToken: string;
applyToRequest(requestOptions: request.Options): void {
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
if (requestOptions && requestOptions.headers) {
requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
}
}
}
export class VoidAuth implements Authentication {
public username: string;
public password: string;
applyToRequest(requestOptions: request.Options): void {
applyToRequest(_: request.Options): void {
// Do nothing
}
}
@@ -98,13 +88,13 @@ export enum FakeApiApiKeys {
}
export class FakeApi {
protected basePath = defaultBasePath;
protected _basePath = defaultBasePath;
protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false;
protected authentications = {
'default': <Authentication>new VoidAuth(),
'api_key': new ApiKeyAuth('header', 'api_key */ &#39; &quot; &#x3D;end \r\n \n \r'),
'api_key': new ApiKeyAuth('header', 'api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r'),
'petstore_auth': new OAuth(),
}
@@ -125,6 +115,14 @@ export class FakeApi {
this._useQuerystring = value;
}
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: FakeApiApiKeys, value: string) {
this.authentications[FakeApiApiKeys[key]].apiKey = value;
}
@@ -132,30 +130,22 @@ export class FakeApi {
set accessToken(token: string) {
this.authentications.petstore_auth.accessToken = token;
}
private extendObj<T1,T2>(objA: T1, objB: T2) {
for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
/**
* To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
* To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
*
* @param test code inject * &#39; &quot; &#x3D;end rn n r To test code injection *_/ &#39; \&quot; &#x3D;end \\r\\n \\n \\r
* @param test code inject * &#39; &quot; &#x3D;end rn n r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
*/
public testCodeInjectEndRnNR (test code inject * &#39; &quot; &#x3D;end rn n r?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
public testCodeInjectEndRnNR (test code inject * &#39; &quot; &#x3D;end rn n r?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
const localVarPath = this.basePath + '/fake';
let queryParameters: any = {};
let headerParams: any = this.extendObj({}, this.defaultHeaders);
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {};
let useFormData = false;
if (test code inject * &#39; &quot; &#x3D;end rn n r !== undefined) {
formParams['test code inject */ &#39; &quot; &#x3D;end \r\n \n \r'] = test code inject * &#39; &quot; &#x3D;end rn n r;
if (test code inject * &#39; &quot; &#x3D;end rn n r !== undefined) {
formParams['test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r'] = test code inject * &#39; &quot; &#x3D;end rn n r;
}
let requestOptions: request.Options = {