Skip to content

Commit

Permalink
Merge pull request #1762 from lnash94/function-breakdown
Browse files Browse the repository at this point in the history
Restructure the name modification function
  • Loading branch information
lnash94 authored Aug 23, 2024
2 parents e4c0dd7 + 01fa8a4 commit 8fde6dd
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 153 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
2 changes: 1 addition & 1 deletion module-ballerina-openapi/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[package]
org= "ballerina"
name= "openapi"
version= "@toml.version@"
version= "2.1.1"
4 changes: 2 additions & 2 deletions module-ballerina-openapi/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id = "openapi-tools"
class = "io.ballerina.openapi.validator.OpenAPIValidatorPlugin"

[[dependency]]
path = "../openapi-validator/build/libs/openapi-validator-@project.version@.jar"
path = "../openapi-validator/build/libs/openapi-validator-2.1.1-SNAPSHOT.jar"
groupId = "ballerina"
artifactId = "openapi"
version = "@project.version@."
version = "2.1.1-SNAPSHOT"
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 8fde6dd

Please sign in to comment.