forked from loafle/openapi-generator-original
typescript-node: Fix cookie auth, fix multiple API key auth (#3927)
* typescript-node: Fix cookie auth, fix multiple API key auth * Re-generate samples * Re-generate samples
This commit is contained in:
parent
b867a6c3d5
commit
6f1b8ef658
@ -9,17 +9,7 @@ import { {{classname}} } from '../{{filename}}';
|
|||||||
|
|
||||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}
|
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||||
{{#isBasic}}
|
|
||||||
import { HttpBasicAuth } from '../model/models';
|
|
||||||
{{/isBasic}}
|
|
||||||
{{#isApiKey}}
|
|
||||||
import { ApiKeyAuth } from '../model/models';
|
|
||||||
{{/isApiKey}}
|
|
||||||
{{#isOAuth}}
|
|
||||||
import { OAuth } from '../model/models';
|
|
||||||
{{/isOAuth}}
|
|
||||||
{{/authMethods}}
|
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
import { HttpError } from './apis';
|
import { HttpError } from './apis';
|
||||||
@ -57,7 +47,7 @@ export class {{classname}} {
|
|||||||
'{{name}}': new HttpBasicAuth(),
|
'{{name}}': new HttpBasicAuth(),
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
'{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{^isKeyInHeader}}'query'{{/isKeyInHeader}}, '{{keyParamName}}'),
|
'{{name}}': new ApiKeyAuth({{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}{{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}, '{{keyParamName}}'),
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
'{{name}}': new OAuth(),
|
'{{name}}': new OAuth(),
|
||||||
|
@ -23,7 +23,7 @@ let primitives = [
|
|||||||
"number",
|
"number",
|
||||||
"any"
|
"any"
|
||||||
];
|
];
|
||||||
|
|
||||||
let enumsMap: {[index: string]: any} = {
|
let enumsMap: {[index: string]: any} = {
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
@ -110,7 +110,7 @@ export class ObjectSerializer {
|
|||||||
if (!typeMap[type]) { // in case we dont know the type
|
if (!typeMap[type]) { // in case we dont know the type
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the actual type of this object
|
// Get the actual type of this object
|
||||||
type = this.findCorrectType(data, type);
|
type = this.findCorrectType(data, type);
|
||||||
|
|
||||||
@ -191,6 +191,13 @@ export class ApiKeyAuth implements Authentication {
|
|||||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||||
requestOptions.headers[this.paramName] = this.apiKey;
|
requestOptions.headers[this.paramName] = this.apiKey;
|
||||||
|
} else if (this.location == 'cookie' && requestOptions && requestOptions.headers) {
|
||||||
|
if (requestOptions.headers['Cookie']) {
|
||||||
|
requestOptions.headers['Cookie'] += '; ' + this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
requestOptions.headers['Cookie'] = this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ import { ApiResponse } from '../model/apiResponse';
|
|||||||
import { Pet } from '../model/pet';
|
import { Pet } from '../model/pet';
|
||||||
|
|
||||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||||
import { OAuth } from '../model/models';
|
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||||
import { ApiKeyAuth } from '../model/models';
|
|
||||||
|
|
||||||
import { HttpError } from './apis';
|
import { HttpError } from './apis';
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import http = require('http');
|
|||||||
import { Order } from '../model/order';
|
import { Order } from '../model/order';
|
||||||
|
|
||||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||||
import { ApiKeyAuth } from '../model/models';
|
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||||
|
|
||||||
import { HttpError } from './apis';
|
import { HttpError } from './apis';
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* OpenAPI Petstore
|
* OpenAPI Petstore
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0
|
* The version of the OpenAPI document: 1.0.0
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* OpenAPI Petstore
|
* OpenAPI Petstore
|
||||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
*
|
*
|
||||||
* OpenAPI spec version: 1.0.0
|
* The version of the OpenAPI document: 1.0.0
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
@ -25,7 +25,7 @@ let primitives = [
|
|||||||
"number",
|
"number",
|
||||||
"any"
|
"any"
|
||||||
];
|
];
|
||||||
|
|
||||||
let enumsMap: {[index: string]: any} = {
|
let enumsMap: {[index: string]: any} = {
|
||||||
"Order.StatusEnum": Order.StatusEnum,
|
"Order.StatusEnum": Order.StatusEnum,
|
||||||
"Pet.StatusEnum": Pet.StatusEnum,
|
"Pet.StatusEnum": Pet.StatusEnum,
|
||||||
@ -99,7 +99,7 @@ export class ObjectSerializer {
|
|||||||
if (!typeMap[type]) { // in case we dont know the type
|
if (!typeMap[type]) { // in case we dont know the type
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the actual type of this object
|
// Get the actual type of this object
|
||||||
type = this.findCorrectType(data, type);
|
type = this.findCorrectType(data, type);
|
||||||
|
|
||||||
@ -180,6 +180,13 @@ export class ApiKeyAuth implements Authentication {
|
|||||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||||
requestOptions.headers[this.paramName] = this.apiKey;
|
requestOptions.headers[this.paramName] = this.apiKey;
|
||||||
|
} else if (this.location == 'cookie' && requestOptions && requestOptions.headers) {
|
||||||
|
if (requestOptions.headers['Cookie']) {
|
||||||
|
requestOptions.headers['Cookie'] += '; ' + this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
requestOptions.headers['Cookie'] = this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@ import { ApiResponse } from '../model/apiResponse';
|
|||||||
import { Pet } from '../model/pet';
|
import { Pet } from '../model/pet';
|
||||||
|
|
||||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||||
import { OAuth } from '../model/models';
|
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||||
import { ApiKeyAuth } from '../model/models';
|
|
||||||
|
|
||||||
import { HttpError } from './apis';
|
import { HttpError } from './apis';
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import http = require('http');
|
|||||||
import { Order } from '../model/order';
|
import { Order } from '../model/order';
|
||||||
|
|
||||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||||
import { ApiKeyAuth } from '../model/models';
|
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||||
|
|
||||||
import { HttpError } from './apis';
|
import { HttpError } from './apis';
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ let primitives = [
|
|||||||
"number",
|
"number",
|
||||||
"any"
|
"any"
|
||||||
];
|
];
|
||||||
|
|
||||||
let enumsMap: {[index: string]: any} = {
|
let enumsMap: {[index: string]: any} = {
|
||||||
"Order.StatusEnum": Order.StatusEnum,
|
"Order.StatusEnum": Order.StatusEnum,
|
||||||
"Pet.StatusEnum": Pet.StatusEnum,
|
"Pet.StatusEnum": Pet.StatusEnum,
|
||||||
@ -99,7 +99,7 @@ export class ObjectSerializer {
|
|||||||
if (!typeMap[type]) { // in case we dont know the type
|
if (!typeMap[type]) { // in case we dont know the type
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the actual type of this object
|
// Get the actual type of this object
|
||||||
type = this.findCorrectType(data, type);
|
type = this.findCorrectType(data, type);
|
||||||
|
|
||||||
@ -180,6 +180,13 @@ export class ApiKeyAuth implements Authentication {
|
|||||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||||
requestOptions.headers[this.paramName] = this.apiKey;
|
requestOptions.headers[this.paramName] = this.apiKey;
|
||||||
|
} else if (this.location == 'cookie' && requestOptions && requestOptions.headers) {
|
||||||
|
if (requestOptions.headers['Cookie']) {
|
||||||
|
requestOptions.headers['Cookie'] += '; ' + this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
requestOptions.headers['Cookie'] = this.paramName + '=' + encodeURIComponent(this.apiKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user