Skip to content

Commit

Permalink
Merge pull request #8 from andreferreiratrindade/main
Browse files Browse the repository at this point in the history
Added property TypeChange
  • Loading branch information
andretrindade authored Jan 22, 2024
2 parents c79fbfe + eea16de commit 748ef17
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/dtos/ChangeLogDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export default class ChangeLogDTO {
public oldValue?: String
public path!: string;
public field!: string;
public changeType!: string;
}
2 changes: 2 additions & 0 deletions src/dtos/ChangeLogViewOutputDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export default class ChangeLogViewOutputDTO {
public oldValue?: String
public currentValue?: String
public path!: String
public changeType!: string;

}
3 changes: 2 additions & 1 deletion src/services/ChangeLogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ export default class ChangeLogService {
private createChangeLog(change: ChangeDTO, templateDescription?: TemplateDescriptionDTO): ChangeLogDTO {

let description = CustomDescriptionChangeLogService.addCustomChangeDescription(change, templateDescription);

let changeTypeText = CustomDescriptionChangeLogService.getChangeTypeDescription(change.typeChange)
let changeLog: ChangeLogDTO =
{
change: change,
path: change.path.join('/'),
field: change.field,
currentValue: change.valueCurrent,
oldValue: change.valueOld,
changeType : changeTypeText,
description: description
}

Expand Down
18 changes: 18 additions & 0 deletions src/services/CustomDescriptionChangeLogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ChangeDTO from "../dtos/ChangeDTO";

export default class CustomDescriptionChangeLogService {


public static addCustomChangeDescription(change: ChangeDTO, templateDescription?: TemplateDescriptionDTO): string {
const { field, valueCurrent } = change;

Expand All @@ -29,6 +30,23 @@ export default class CustomDescriptionChangeLogService {
return description;
}

public static getChangeTypeDescription(changeTypeDescription: TypeChange): string{
let type = "";
switch (changeTypeDescription) {
case TypeChange.added:
type = "Adição"
break;
case TypeChange.removed:
type = "Remoção"
break;
case TypeChange.edited:
type = "Alteração"
break;
}

return type;
}

private static addCustomDescriptionByValue(valueCurrent: string = "", textOld: string, templateRequired?: string) {
let description = textOld;

Expand Down
3 changes: 2 additions & 1 deletion src/services/FormattingChangeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default class FormattingChangeService {
description: change.description,
currentValue: this.formatValueAsString(change.currentValue),
oldValue: this.formatValueAsString(change.oldValue),
path: this.replaceWord(change.path.replace(changePerEndPoint.endpoint, ""))
path: this.replaceWord(change.path.replace(changePerEndPoint.endpoint, "")),
changeType : change.changeType
};
changeLogViewOutputList.push(changeLogViewOutputDto);
});
Expand Down
11 changes: 9 additions & 2 deletions tests/httpTest/changelog.http
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
POST https://8j5hhxm684.execute-api.us-west-2.amazonaws.com/development/change-log HTTP/1.1
POST https://88v16tfb0l.execute-api.sa-east-1.amazonaws.com/development/change-log HTTP/1.1
content-type: application/json

{
"urlCurrent": "https://raw.githubusercontent.com/OpenBanking-Brasil/draft-openapi/main/swagger-apis/channels/2.0.0-rc.1.yml",
"urlOld": "https://raw.githubusercontent.com/OpenBanking-Brasil/draft-openapi/main/swagger-apis/channels/2.0.0-beta.1.yml"
}
###
POST https://88v16tfb0l.execute-api.sa-east-1.amazonaws.com/development/change-log HTTP/1.1
content-type: application/json

{
"urlOld": "https://raw.githubusercontent.com/OpenBanking-Brasil/openapi/main/swagger-apis/accounts/1.0.3.yml",
"urlCurrent": "https://raw.githubusercontent.com/OpenBanking-Brasil/openapi/main/swagger-apis/accounts/2.0.0.yml"
}
###

POST http://localhost:3000/development/change-log HTTP/1.1
content-type: application/json

Expand Down
4 changes: 2 additions & 2 deletions tests/services/ChangeLogGeneratorService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('testing ChangeLogGeneratorService file', () => {


let changeLogGeneratorService = new ChangeLogGeneratorService();
let urlOld = "https://raw.githubusercontent.com/Sensedia/draft-openapi/main/swagger-apis/resources/1.0.2.yml";
let urlCurrent = "https://raw.githubusercontent.com/Sensedia/draft-openapi/main/swagger-apis/resources/2.0.0.yml";
let urlCurrent = "https://raw.githubusercontent.com/OpenBanking-Brasil/draft-openapi/main/swagger-apis/channels/2.0.0-rc.1.yml";
let urlOld = "https://raw.githubusercontent.com/OpenBanking-Brasil/draft-openapi/main/swagger-apis/channels/2.0.0-beta.1.yml";

let requestChangeLog = new ChangeLogRequestDTO();
requestChangeLog.urlOld = urlOld;
Expand Down

0 comments on commit 748ef17

Please sign in to comment.