mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
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';
|
||||
{{#hasAuthMethods}}
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
import { HttpBasicAuth } from '../model/models';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
import { ApiKeyAuth } from '../model/models';
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
import { OAuth } from '../model/models';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||
{{/hasAuthMethods}}
|
||||
|
||||
import { HttpError } from './apis';
|
||||
@ -57,7 +47,7 @@ export class {{classname}} {
|
||||
'{{name}}': new HttpBasicAuth(),
|
||||
{{/isBasic}}
|
||||
{{#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}}
|
||||
{{#isOAuth}}
|
||||
'{{name}}': new OAuth(),
|
||||
|
@ -23,7 +23,7 @@ let primitives = [
|
||||
"number",
|
||||
"any"
|
||||
];
|
||||
|
||||
|
||||
let enumsMap: {[index: string]: any} = {
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
@ -110,7 +110,7 @@ export class ObjectSerializer {
|
||||
if (!typeMap[type]) { // in case we dont know the type
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
// Get the actual type of this object
|
||||
type = this.findCorrectType(data, type);
|
||||
|
||||
@ -191,6 +191,13 @@ export class ApiKeyAuth implements Authentication {
|
||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||
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 { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||
import { OAuth } from '../model/models';
|
||||
import { ApiKeyAuth } from '../model/models';
|
||||
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||
|
||||
import { HttpError } from './apis';
|
||||
|
||||
|
@ -17,7 +17,7 @@ import http = require('http');
|
||||
import { Order } from '../model/order';
|
||||
|
||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||
import { ApiKeyAuth } from '../model/models';
|
||||
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||
|
||||
import { HttpError } from './apis';
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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.
|
||||
*
|
||||
* 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).
|
||||
|
@ -2,7 +2,7 @@
|
||||
* 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.
|
||||
*
|
||||
* 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).
|
||||
|
@ -25,7 +25,7 @@ let primitives = [
|
||||
"number",
|
||||
"any"
|
||||
];
|
||||
|
||||
|
||||
let enumsMap: {[index: string]: any} = {
|
||||
"Order.StatusEnum": Order.StatusEnum,
|
||||
"Pet.StatusEnum": Pet.StatusEnum,
|
||||
@ -99,7 +99,7 @@ export class ObjectSerializer {
|
||||
if (!typeMap[type]) { // in case we dont know the type
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
// Get the actual type of this object
|
||||
type = this.findCorrectType(data, type);
|
||||
|
||||
@ -180,6 +180,13 @@ export class ApiKeyAuth implements Authentication {
|
||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||
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 { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||
import { OAuth } from '../model/models';
|
||||
import { ApiKeyAuth } from '../model/models';
|
||||
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||
|
||||
import { HttpError } from './apis';
|
||||
|
||||
|
@ -17,7 +17,7 @@ import http = require('http');
|
||||
import { Order } from '../model/order';
|
||||
|
||||
import { ObjectSerializer, Authentication, VoidAuth } from '../model/models';
|
||||
import { ApiKeyAuth } from '../model/models';
|
||||
import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models';
|
||||
|
||||
import { HttpError } from './apis';
|
||||
|
||||
|
@ -25,7 +25,7 @@ let primitives = [
|
||||
"number",
|
||||
"any"
|
||||
];
|
||||
|
||||
|
||||
let enumsMap: {[index: string]: any} = {
|
||||
"Order.StatusEnum": Order.StatusEnum,
|
||||
"Pet.StatusEnum": Pet.StatusEnum,
|
||||
@ -99,7 +99,7 @@ export class ObjectSerializer {
|
||||
if (!typeMap[type]) { // in case we dont know the type
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
// Get the actual type of this object
|
||||
type = this.findCorrectType(data, type);
|
||||
|
||||
@ -180,6 +180,13 @@ export class ApiKeyAuth implements Authentication {
|
||||
(<any>requestOptions.qs)[this.paramName] = this.apiKey;
|
||||
} else if (this.location == "header" && requestOptions && requestOptions.headers) {
|
||||
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