Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure the name modification function #1762

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
TharmiganK marked this conversation as resolved.
Show resolved Hide resolved
}
return openAPI;
}
Expand Down
Loading
Loading