Skip to content

Commit

Permalink
Merge pull request #218 from vitalymatyushik/feature/fix-duplicate-code
Browse files Browse the repository at this point in the history
Feature/fix duplicate code
  • Loading branch information
brunobuddy authored Nov 15, 2024
2 parents a3f34aa + 78e3ff4 commit 309ab55
Showing 1 changed file with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ export class OpenApiAuthService {
.filter((entity: EntityManifest) => entity.authenticable)
.concat(ADMIN_ENTITY_MANIFEST)

const successfulAuthResponse = {
'application/json': {
schema: {
type: 'object',
properties: {
token: {
type: 'string'
}
}
},
example: {
token: '12345'
}
}
}

authenticableEntities.forEach((entity: EntityManifest) => {
// Login.
paths[`/api/auth/${entity.slug}/login`] = {
Expand Down Expand Up @@ -58,21 +74,7 @@ export class OpenApiAuthService {
responses: {
'200': {
description: 'Successful login',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
token: {
type: 'string'
}
}
},
example: {
token: '12345'
}
}
}
content: successfulAuthResponse
},
'401': {
description: 'Invalid credentials',
Expand Down Expand Up @@ -229,21 +231,7 @@ export class OpenApiAuthService {
responses: {
'200': {
description: 'Successful signup',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
token: {
type: 'string'
}
}
},
example: {
token: '12345'
}
}
}
content: successfulAuthResponse
},
'400': {
description: 'Bad request',
Expand Down

0 comments on commit 309ab55

Please sign in to comment.