Skip to content

Commit

Permalink
update getSchemaType variable, remove unused import (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored May 8, 2018
1 parent 27b3302 commit db9a899
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ public String getTypeDeclaration(Schema p) {

@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
String openAPIType = super.getSchemaType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
return toModelName(type);
}
} else {
type = swaggerType;
type = openAPIType;
}
return toModelName(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public BashClientCodegen() {
"Whether to generate the Zsh completion script"));
cliOptions.add(CliOption.newString(HOST_ENVIRONMENT_VARIABLE_NAME,
"Name of environment variable where host can be defined " +
"(e.g. PETSTORE_HOST='http://petstore.swagger.io:8080')"));
"(e.g. PETSTORE_HOST='http://api.openapitools.org:8080')"));
cliOptions.add(CliOption.newString(BASIC_AUTH_ENVIRONMENT_VARIABLE_NAME,
"Name of environment variable where username and password "
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,21 @@ public String getTypeDeclaration(Schema p) {
}

/**
* Optional - swagger type conversion. This is used to map swagger types in a `Schema` into
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
*
* @return a string value of the type or complex model for this property
*/
@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
String openAPIType = super.getSchemaType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type))
return toModelName(type);
} else
type = swaggerType;
type = openAPIType;
return toModelName(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String CORE_DATA = "coreData";

protected Set<String> foundationClasses = new HashSet<String>();
protected String podName = "SwaggerClient";
protected String podName = "OpenAPIClient";
protected String podVersion = "1.0.0";
protected String classPrefix = "SWG";
protected String authorName = "Swagger";
protected String authorName = "OpenAPI";
protected String authorEmail = "[email protected]";
protected String license = DEFAULT_LICENSE;
protected String gitRepoURL = "https://github.com/openapitools/openapi-generator";
Expand Down Expand Up @@ -191,10 +191,10 @@ public ObjcClientCodegen() {
cliOptions.add(new CliOption(CLASS_PREFIX, "prefix for generated classes (convention: Abbreviation of pod name e.g. `HN` for `HackerNews`).`")
.defaultValue("SWG"));
cliOptions.add(new CliOption(POD_NAME, "cocoapods package name (convention: CameCase).")
.defaultValue("SwaggerClient"));
.defaultValue("OpenAPIClient"));
cliOptions.add(new CliOption(CodegenConstants.POD_VERSION, "cocoapods package version.")
.defaultValue("1.0.0"));
cliOptions.add(new CliOption(AUTHOR_NAME, "Name to use in the podspec file.").defaultValue("Swagger"));
cliOptions.add(new CliOption(AUTHOR_NAME, "Name to use in the podspec file.").defaultValue("OpenAPI"));
cliOptions.add(new CliOption(AUTHOR_EMAIL, "Email to use in the podspec file.").defaultValue("[email protected]"));
cliOptions.add(new CliOption(GIT_REPO_URL, "URL for the git repo where this podspec should point to.")
.defaultValue("https://github.com/openapitools/openapi-generator"));
Expand Down Expand Up @@ -329,21 +329,21 @@ public String getTypeDeclaration(String name) {

@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
String openAPIType = super.getSchemaType(p);
String type = null;

if (swaggerType == null) {
swaggerType = ""; // set swagger type to empty string if null
if (openAPIType == null) {
openAPIType = ""; // set OpenAPI type to empty string if null
}

// TODO avoid using toLowerCase as typeMapping should be case-sensitive
if (typeMapping.containsKey(swaggerType.toLowerCase())) {
type = typeMapping.get(swaggerType.toLowerCase());
if (typeMapping.containsKey(openAPIType.toLowerCase())) {
type = typeMapping.get(openAPIType.toLowerCase());
if (languageSpecificPrimitives.contains(type) && !foundationClasses.contains(type)) {
return toModelNameWithoutReservedWordCheck(type);
}
} else {
type = swaggerType;
type = openAPIType;
}
return toModelNameWithoutReservedWordCheck(type);
}
Expand Down Expand Up @@ -391,22 +391,22 @@ public String getTypeDeclaration(Schema p) {
return getSchemaType(p) + "<" + innerTypeDeclaration + ">*";
}
} else {
String swaggerType = getSchemaType(p);
String openAPIType = getSchemaType(p);
// In this condition, type of p is objective-c primitive type, e.g. `NSSNumber',
// return type of p with pointer, e.g. `NSNumber*'
if (languageSpecificPrimitives.contains(swaggerType) &&
foundationClasses.contains(swaggerType)) {
return swaggerType + "*";
if (languageSpecificPrimitives.contains(openAPIType) &&
foundationClasses.contains(openAPIType)) {
return openAPIType + "*";
}
// In this condition, type of p is c primitive type, e.g. `bool',
// return type of p, e.g. `bool'
else if (languageSpecificPrimitives.contains(swaggerType)) {
return swaggerType;
else if (languageSpecificPrimitives.contains(openAPIType)) {
return openAPIType;
}
// In this condition, type of p is objective-c object type, e.g. `SWGPet',
// return type of p with pointer, e.g. `SWGPet*'
else {
return swaggerType + "*";
return openAPIType + "*";
}
}
}
Expand Down Expand Up @@ -658,7 +658,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty schema)
/**
* Return the default value of the schema
*
* @param p Swagger schema object
* @param p OpenAPI schema object
* @return string presentation of the default value of the schema
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ public String getTypeDeclaration(Schema p) {

@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
String openAPIType = super.getSchemaType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
return type;
} else if (instantiationTypes.containsKey(type)) {
return type;
}
} else {
type = swaggerType;
type = openAPIType;
}
if (type == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openapitools.codegen.languages;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
Expand All @@ -28,8 +27,6 @@
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.core.util.Yaml;

import java.io.File;
import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.JbossFeature;
import org.openapitools.codegen.languages.features.SwaggerFeatures;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.media.*;

Expand Down Expand Up @@ -181,12 +178,12 @@ public String getTypeDeclaration(Schema p) {

@Override
public String getSchemaType(Schema p) {
String swaggerType = super.getSchemaType(p);
if (isLanguagePrimitive(swaggerType) || isLanguageGenericType(swaggerType)) {
return swaggerType;
String openAPIType = super.getSchemaType(p);
if (isLanguagePrimitive(openAPIType) || isLanguageGenericType(openAPIType)) {
return openAPIType;
}
applyLocalTypeMapping(swaggerType);
return swaggerType;
applyLocalTypeMapping(openAPIType);
return openAPIType;
}

private String applyLocalTypeMapping(String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openapitools.codegen.ruby;

import io.swagger.models.parameters.FormParameter;
import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.RubyClientCodegen;
Expand Down

0 comments on commit db9a899

Please sign in to comment.