Skip to content

Commit

Permalink
fix(hermes): Swagger route tags (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPdgn committed Jul 23, 2022
1 parent 4036888 commit 04549b0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions libraries/hermes/src/Rest/Swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ export class SwaggerGenerator {

addRouteSwaggerDocumentation(route: ConduitRoute) {
const method = this._extractMethod(route.input.action);
let serviceName = route.input.path.toString().replace('/hook', '').slice(1);
serviceName = serviceName.substr(0, serviceName.indexOf('/'));
if (serviceName.trim() === '') {
const baseName = route.input.path.toString().replace('/hook', '').slice(1);
const prefix =
baseName.indexOf('/') !== -1 ? baseName.substring(0, baseName.indexOf('/')) : '';
let serviceName: string;
if (baseName.includes('admin')) {
serviceName = 'admin';
} else if (prefix.trim() === '') {
serviceName = 'core';
} else {
serviceName = prefix;
}
const routeDoc: Indexable = {
summary: route.input.name,
Expand All @@ -66,7 +72,7 @@ export class SwaggerGenerator {

if (
!isNil(route.input.urlParams) &&
((route.input.urlParams as unknown) as string) !== ''
(route.input.urlParams as unknown as string) !== ''
) {
for (const name in route.input.urlParams) {
routeDoc.parameters.push({
Expand All @@ -80,7 +86,7 @@ export class SwaggerGenerator {

if (
!isNil(route.input.queryParams) &&
((route.input.queryParams as unknown) as string) !== ''
(route.input.queryParams as unknown as string) !== ''
) {
for (const name in route.input.queryParams) {
routeDoc.parameters.push({
Expand All @@ -93,7 +99,7 @@ export class SwaggerGenerator {

if (
!isNil(route.input.bodyParams) &&
((route.input.bodyParams as unknown) as string) !== ''
(route.input.bodyParams as unknown as string) !== ''
) {
routeDoc['requestBody'] = {
description: route.input.description,
Expand Down

0 comments on commit 04549b0

Please sign in to comment.