Skip to content

Commit

Permalink
Merge pull request #1764 from ballerina-platform/function-break-down
Browse files Browse the repository at this point in the history
[master] Restructure the name modification function
  • Loading branch information
lnash94 authored Aug 23, 2024
2 parents f36dac1 + 6dbec73 commit e5bd587
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# See: https://help.github.com/articles/about-codeowners/

# These owners will be the default owners for everything in the repo.
* @hevayo @nipunaranasinghe @lnash94
* @lnash94 @TharmiganK
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Optional;

/**
* This contains the OAS modification tests.
Expand All @@ -39,8 +41,9 @@ public void testForRecordName() throws IOException, BallerinaOpenApiException {
Path definitionPath = RES_DIR.resolve("record.yaml");
Path expectedPath = RES_DIR.resolve("modified_record.yaml");
OpenAPI openAPI = GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(definitionPath);
OASModifier oasModifier = new OASModifier(openAPI);
OpenAPI modifiedOAS = oasModifier.modifyWithBallerinaConventions();
OASModifier oasModifier = new OASModifier();
Optional<Map<String, String>> proposedNameList = oasModifier.getProposedNameList(openAPI);
OpenAPI modifiedOAS = oasModifier.modifyWithBallerinaConventions(openAPI, proposedNameList.get());
// file comparison
OpenAPI expectedFileContent = GeneratorUtils.getOpenAPIFromOpenAPIV3Parser(expectedPath);
Assert.assertEquals(modifiedOAS, expectedFileContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -767,8 +768,12 @@ public static OpenAPI normalizeOpenAPI(OpenAPI openAPI, boolean validateOpIds, b
}
validateRequestBody(openAPIPaths.entrySet());
if (isSanitized) {
OASModifier oasSanitizer = new OASModifier(openAPI);
return oasSanitizer.modifyWithBallerinaConventions();
OASModifier oasSanitizer = new OASModifier();
Optional<Map<String, String>> proposedNameList = oasSanitizer.getProposedNameList(openAPI);
if (proposedNameList.isEmpty()) {
return openAPI;
}
return oasSanitizer.modifyWithBallerinaConventions(openAPI, proposedNameList.get());
}
return openAPI;
}
Expand Down
Loading

0 comments on commit e5bd587

Please sign in to comment.