Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions samples/client/petstore-security-test/scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
66 changes: 28 additions & 38 deletions samples/client/petstore-security-test/typescript-node/api.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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
}
}
Expand All @@ -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(),
}

Expand All @@ -125,37 +115,37 @@ 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;
}

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 = {
Expand Down