Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ import { {{classname}} } from '..{{filename}}{{extensionForDeno}}';
@injectable()
{{/useInversify}}
export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
private defaultSecurityAuthentication: SecurityAuthentication | undefined;

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.defaultSecurityAuthentication = auth;
}


{{#operation}}
/**
{{#notes}}
Expand Down Expand Up @@ -157,15 +152,19 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
{{/bodyParam}}

{{#hasAuthMethods}}
let authMethod = null;
let authMethod: SecurityAuthentication | undefined;
{{/hasAuthMethods}}
{{#authMethods}}
// Apply auth methods
authMethod = defaultSecurityAuthentication || _config.authMethods["{{name}}"]
if (authMethod) {
await authMethod.applySecurityAuthentication(requestContext);
authMethod = _config.authMethods["{{name}}"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
{{/authMethods}}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}

return requestContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class {{#lambda.pascalcase}}{{name}}{{/lambda.pascalcase}}Authentication
{{/authMethods}}

export type AuthMethods = {
"default"?: SecurityAuthentication,
{{#authMethods}}
"{{name}}"?: SecurityAuthentication{{^-last}},{{/-last}}
{{/authMethods}}
Expand All @@ -126,6 +127,7 @@ export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
export type OAuth2Configuration = { accessToken: string };

export type AuthMethodsConfiguration = {
"default"?: SecurityAuthentication,
{{#authMethods}}
"{{name}}"?: {{#isApiKey}}ApiKeyConfiguration{{/isApiKey}}{{#isBasicBasic}}HttpBasicConfiguration{{/isBasicBasic}}{{#isBasicBearer}}HttpBearerConfiguration{{/isBasicBearer}}{{#isOAuth}}OAuth2Configuration{{/isOAuth}}{{^-last}},{{/-last}}
{{/authMethods}}
Expand All @@ -141,6 +143,7 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine
if (!config) {
return authMethods;
}
authMethods["default"] = config["default"]

{{#authMethods}}
if (config["{{name}}"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export abstract class AbstractObject{{classname}} {
{{/summary}}
* @param param the request object
*/
public abstract {{nickname}}(param: req.{{classname}}{{operationIdCamelCase}}Request, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
public abstract {{nickname}}(param: req.{{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{{returnType}}}{{^returnType}}void{{/returnType}}>;

{{/operation}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Object{{classname}} {
{{/summary}}
* @param param the request object
*/
public {{nickname}}(param: {{classname}}{{operationIdCamelCase}}Request, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
public {{nickname}}(param: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, options?: Configuration): {{#useRxJS}}Observable{{/useRxJS}}{{^useRxJS}}Promise{{/useRxJS}}<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
return this.api.{{nickname}}({{#allParams}}param.{{paramName}}, {{/allParams}} options){{^useRxJS}}.toPromise(){{/useRxJS}};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ export class Observable{{classname}} {
this.responseProcessor = responseProcessor || new {{classname}}ResponseProcessor();
}

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.requestFactory.setDefaultSecurityAuthentication(auth);
}

{{#operation}}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export class Promise{{classname}} {
this.api = new Observable{{classname}}(configuration, requestFactory, responseProcessor);
}

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.api.setDefaultSecurityAuthentication(auth);
}

{{#operation}}
/**
{{#notes}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ import { PetByType } from '../models/PetByType';
* no description
*/
export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
<<<<<<< HEAD
private defaultSecurityAuthentication: SecurityAuthentication | undefined;

public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.defaultSecurityAuthentication = auth;
}

=======

>>>>>>> 36eb3046d177f220ab68baafb9a64ef1df308571
/**
* @param inlineObject
*/
Expand All @@ -50,6 +54,10 @@ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
);
requestContext.setBody(serializedBody);

const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth) {
await authMethod.applySecurityAuthentication(requestContext);
}

return requestContext;
}
Expand Down Expand Up @@ -80,6 +88,10 @@ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
);
requestContext.setBody(serializedBody);

const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth) {
await authMethod.applySecurityAuthentication(requestContext);
}

return requestContext;
}
Expand Down Expand Up @@ -110,6 +122,10 @@ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
);
requestContext.setBody(serializedBody);

const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth) {
await authMethod.applySecurityAuthentication(requestContext);
}

return requestContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface TokenProvider {


export type AuthMethods = {
"default"?: SecurityAuthentication,
}

export type ApiKeyConfiguration = string;
Expand All @@ -32,6 +33,7 @@ export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
export type OAuth2Configuration = { accessToken: string };

export type AuthMethodsConfiguration = {
"default"?: SecurityAuthentication,
}

/**
Expand All @@ -44,6 +46,7 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine
if (!config) {
return authMethods;
}
authMethods["default"] = config["default"]

return authMethods;
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ export class ObjectDefaultApi {
/**
* @param param the request object
*/
public filePost(param: DefaultApiFilePostRequest, options?: Configuration): Promise<void> {
public filePost(param: DefaultApiFilePostRequest = {}, options?: Configuration): Promise<void> {
return this.api.filePost(param.inlineObject, options).toPromise();
}

/**
* @param param the request object
*/
public petsFilteredPatch(param: DefaultApiPetsFilteredPatchRequest, options?: Configuration): Promise<void> {
public petsFilteredPatch(param: DefaultApiPetsFilteredPatchRequest = {}, options?: Configuration): Promise<void> {
return this.api.petsFilteredPatch(param.petByAgePetByType, options).toPromise();
}

/**
* @param param the request object
*/
public petsPatch(param: DefaultApiPetsPatchRequest, options?: Configuration): Promise<void> {
public petsPatch(param: DefaultApiPetsPatchRequest = {}, options?: Configuration): Promise<void> {
return this.api.petsPatch(param.catDog, options).toPromise();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export class ObservableDefaultApi {
this.responseProcessor = responseProcessor || new DefaultApiResponseProcessor();
}

<<<<<<< HEAD
public setDefaultSecurityAuthentication(auth: SecurityAuthentication){
this.requestFactory.setDefaultSecurityAuthentication(auth);
}
=======
>>>>>>> 36eb3046d177f220ab68baafb9a64ef1df308571

/**
* @param inlineObject
Expand Down
Loading