Skip to content

Commit

Permalink
Merge pull request #1627 from ballerina-platform/enable-test
Browse files Browse the repository at this point in the history
Re-enable escape identifier test after lang changes
  • Loading branch information
lnash94 authored Mar 25, 2024
2 parents b8b7f1d + 0b37847 commit 4fbd0e6
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.stream.Collectors;

import static io.ballerina.compiler.syntax.tree.SyntaxKind.STRING_LITERAL;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.removeStartingSingleQuote;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.unescapeIdentifier;

/**
Expand Down Expand Up @@ -80,7 +79,7 @@ public HeaderParameterMapper(ParameterNode parameterNode, Map<String, String> ap
String paramName = unescapeIdentifier(parameterSymbol.getName().get());
this.name = getHeaderName(parameterNode, paramName);
this.isRequired = headerParameter.paramKind().equals(ParameterKind.REQUIRED);
this.description = apiDocs.get(removeStartingSingleQuote(headerParameter.getName().get()));
this.description = apiDocs.get(headerParameter.getName().get());
this.treatNilableAsOptional = treatNilableAsOptional;
if (parameterNode instanceof DefaultableParameterNode defaultableHeaderParam) {
this.defaultValue = AbstractParameterMapper.getDefaultValue(defaultableHeaderParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.util.Map;

import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.removeStartingSingleQuote;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.unescapeIdentifier;

/**
Expand All @@ -55,7 +54,7 @@ public PathParameterMapper(PathParameterSymbol pathParameterSymbol, Map<String,
this.type = pathParameterSymbol.typeDescriptor();
this.typeMapper = typeMapper;
this.name = unescapeIdentifier(pathParameterSymbol.getName().get());
this.description = apiDocs.get(removeStartingSingleQuote(pathParameterSymbol.getName().get()));
this.description = apiDocs.get(pathParameterSymbol.getName().get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.Map;
import java.util.Objects;

import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.removeStartingSingleQuote;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.unescapeIdentifier;

/**
Expand Down Expand Up @@ -65,7 +64,7 @@ public QueryParameterMapper(ParameterNode parameterNode, Map<String, String> api
this.type = queryParameter.typeDescriptor();
this.name = unescapeIdentifier(queryParameter.getName().get());
this.isRequired = queryParameter.paramKind().equals(ParameterKind.REQUIRED);
this.description = apiDocs.get(removeStartingSingleQuote(queryParameter.getName().get()));
this.description = apiDocs.get(queryParameter.getName().get());
this.treatNilableAsOptional = treatNilableAsOptional;
this.semanticModel = additionalData.semanticModel();
this.typeMapper = typeMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static io.ballerina.openapi.service.mapper.Constants.HTTP_PAYLOAD;
import static io.ballerina.openapi.service.mapper.Constants.MEDIA_TYPE;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.extractAnnotationFieldDetails;
import static io.ballerina.openapi.service.mapper.utils.MapperCommonUtils.removeStartingSingleQuote;

/**
* This {@link RequestBodyMapper} class represents the request body mapper.
Expand All @@ -65,7 +64,7 @@ public RequestBodyMapper(ParameterSymbol reqParameter, AnnotationNode annotation
this.semanticModel = additionalData.semanticModel();
this.operationInventory = operationInventory;
this.mediaTypeSubTypePrefix = MediaTypeUtils.extractCustomMediaType(resourceNode).orElse("");
requestBody.description(apiDocs.get(removeStartingSingleQuote(reqParameter.getName().get())));
requestBody.description(apiDocs.get(reqParameter.getName().get()));
extractAnnotationDetails(annotation);
createReqBodyMapping(reqParameter.typeDescriptor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ public static String unescapeIdentifier(String parameterName) {
return unescapedParamName.replaceAll("\\\\", "").replaceAll("'", "");
}

public static String removeStartingSingleQuote(String parameterName) {
return parameterName.replaceAll("^'", "");
}

public static String getTypeDescription(TypeReferenceTypeSymbol typeSymbol) {
Symbol definition = typeSymbol.definition();
if (definition instanceof Documentable) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ group=io.ballerina
version=1.9.0-SNAPSHOT

#dependency
ballerinaLangVersion=2201.9.0-20240319-094400-0453ecf0
ballerinaLangVersion=2201.9.0-20240321-151100-d7ddbc40
testngVersion=7.6.1
slf4jVersion=1.7.30
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ public void testForNonHttpServices() {
Assert.assertTrue(!Files.exists(tempDir.resolve("query_openapi.yaml")));
}

// Disabling this test case because of a breaking change in ballerina lang:
// Lang change: https://github.com/ballerina-platform/ballerina-lang/pull/42342
// Tracking issue: https://github.com/ballerina-platform/ballerina-library/issues/6217
@Test(description = "Given ballerina service has escape character", enabled = false)
@Test(description = "Given ballerina service has escape character")
public void testForRemovingEscapeIdentifier() throws IOException {
Path ballerinaFilePath = RES_DIR.resolve("escape_identifier.bal");
Path tempDir = Files.createTempDirectory("bal-to-openapi-test-out-" + System.nanoTime());
Expand Down

0 comments on commit 4fbd0e6

Please sign in to comment.