Skip to content

Commit

Permalink
Changes for pr#19 and pr#63
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingmik committed Apr 13, 2021
2 parents 6f67e2e + 99c69c8 commit c43e1d7
Show file tree
Hide file tree
Showing 5 changed files with 7,735 additions and 8,485 deletions.
6 changes: 6 additions & 0 deletions lib/swagger-express-ts-lib/src/i-api-operation-args.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export interface IApiOperationArgsBase {
*/
consumes?: string[];

/**
* Define tags
* Optional.
*/
tags?: string[];

/**
* Define path
* Optional.
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger-express-ts-lib/src/i-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface ISwaggerOperation {
produces?: string[];
consumes?: string[];
responses?: { [key: string]: ISwaggerOperationResponse };
security?: Array<{ [key: string]: any[] }>;
security?: { [key: string]: any[] }[];
deprecated?: boolean;
}

Expand Down
12 changes: 10 additions & 2 deletions lib/swagger-express-ts-lib/src/swagger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ export class SwaggerService {
operation.consumes = args.consumes;
}

if (args.tags && args.tags.length > 0) {
operation.tags = args.tags;
}

if (args.deprecated) {
operation.deprecated = args.deprecated;
}
Expand Down Expand Up @@ -702,7 +706,7 @@ export class SwaggerService {

private buildOperationSecurity(argsSecurity: {
[key: string]: any[];
}): Array<{ [key: string]: any[] }> {
}): { [key: string]: any[] }[] {
const securityToReturn = [];
for (const securityIndex in argsSecurity) {
const security: any[] = argsSecurity[securityIndex];
Expand Down Expand Up @@ -767,7 +771,11 @@ export class SwaggerService {
operation.responses
);
}
operation.tags = [_.upperFirst(controller.name)];
if (operation.tags && operation.tags.length > 0) {
operation.tags.unshift(_.upperFirst(controller.name));
} else {
operation.tags = [_.upperFirst(controller.name)];
}
return operation;
}

Expand Down
Loading

0 comments on commit c43e1d7

Please sign in to comment.