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

fix: update reserved words #272

Merged
merged 2 commits into from
Oct 13, 2022
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
6 changes: 6 additions & 0 deletions src/main/java/com/twilio/oai/TwilioCodegenAdapter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.twilio.oai;

import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Stream;

Expand Down Expand Up @@ -38,6 +39,11 @@ public void processOpts() {
codegen.additionalProperties().put("apiVersionClass", StringUtils.camelize(version));

codegen.supportingFiles().clear();

Arrays.asList("Configuration", "Parameter", "Version").forEach(word -> {
codegen.reservedWords().remove(word);
codegen.reservedWords().remove(word.toLowerCase());
});
}

public void setDomain(final String domain) {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/twilio/oai/common/ApplicationConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ public class ApplicationConstants {
public static final String LIST_END = ">";

public static final String OBJECT = "Object";

public static final String _CONFIGURATION = "_Configuration";

public static final String _VERSION = "_Version";
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.twilio.oai.resolver.csharp;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.twilio.oai.StringHelper;
import com.twilio.oai.common.ApplicationConstants;
import com.twilio.oai.common.EnumConstants;
import com.twilio.oai.resolver.Resolver;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.IJsonSchemaValidationProperties;

import java.util.HashSet;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.IJsonSchemaValidationProperties;

public class CodegenParameterResolver implements Resolver<CodegenParameter> {
private final Map<String, Map<String, Object>> conventionMap;
private String className;
Expand Down Expand Up @@ -62,17 +63,8 @@ private boolean isContainerType(CodegenParameter parameter){
return false;
}

public List<CodegenParameter> resolveParameters(List<CodegenParameter> parameters) {
for (CodegenParameter parameter: parameters) {
// Adding reserved keyword for backward compatibility
if (ApplicationConstants._CONFIGURATION.equals(parameter.paramName)) {
parameter.paramName = "Configuration";
} else if (ApplicationConstants._VERSION.equals(parameter.paramName)) {
parameter.paramName = "Version";
}
resolve(parameter);
}
return parameters;
public void resolveParameters(List<CodegenParameter> parameters) {
parameters.forEach(this::resolve);
}

public static Map<String, Map<String, Object>> getConventionalMap() {
Expand Down Expand Up @@ -115,5 +107,4 @@ public void setHasEnumsInOptions(boolean hasEnumsInOptions) {
public void setEnumsDict(HashSet<String> enumsDict) {
this.enumsDict = enumsDict;
}

}