Add support for the URI format (#3023)

* Add support for URI formats

* Set URI type for all generators
This commit is contained in:
Erik Timmers 2019-05-29 13:35:30 +02:00 committed by William Cheng
parent f93e75b078
commit 44e4dc3ff4
55 changed files with 85 additions and 4 deletions

View File

@ -33,7 +33,7 @@ public class CodegenParameter {
public String example; // example value (x-example)
public String jsonSchema;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isFile;
public boolean isEnum;
@ -168,6 +168,7 @@ public class CodegenParameter {
output.isDate = this.isDate;
output.isDateTime = this.isDateTime;
output.isUuid = this.isUuid;
output.isUri = this.isUri;
output.isEmail = this.isEmail;
output.isFreeFormObject = this.isFreeFormObject;
output.isListContainer = this.isListContainer;
@ -222,6 +223,7 @@ public class CodegenParameter {
Objects.equals(isDate, that.isDate) &&
Objects.equals(isDateTime, that.isDateTime) &&
Objects.equals(isUuid, that.isUuid) &&
Objects.equals(isUri, that.isUri) &&
Objects.equals(isEmail, that.isEmail) &&
Objects.equals(isFreeFormObject, that.isFreeFormObject) &&
Objects.equals(isListContainer, that.isListContainer) &&
@ -289,6 +291,7 @@ public class CodegenParameter {
isDate,
isDateTime,
isUuid,
isUri,
isEmail,
isFreeFormObject,
isListContainer,
@ -357,6 +360,7 @@ public class CodegenParameter {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isUri=" + isUri +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +

View File

@ -55,7 +55,7 @@ public class CodegenProperty implements Cloneable {
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
public boolean isPrimitiveType, isModel, isContainer;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
public boolean isEnum;
public boolean isReadOnly;
@ -472,6 +472,7 @@ public class CodegenProperty implements Cloneable {
isDate,
isDateTime,
isUuid,
isUri,
isEmail,
isFreeFormObject,
isMapContainer,
@ -552,6 +553,7 @@ public class CodegenProperty implements Cloneable {
Objects.equals(isDate, other.isDate) &&
Objects.equals(isDateTime, other.isDateTime) &&
Objects.equals(isUuid, other.isUuid) &&
Objects.equals(isUri, other.isUri) &&
Objects.equals(isEmail, other.isEmail) &&
Objects.equals(isFreeFormObject, other.isFreeFormObject) &&
Objects.equals(isBinary, other.isBinary) &&
@ -649,6 +651,7 @@ public class CodegenProperty implements Cloneable {
", isDate=" + isDate +
", isDateTime=" + isDateTime +
", isUuid=" + isUuid +
", isUri=" + isUri +
", isEmail=" + isEmail +
", isFreeFormObject=" + isFreeFormObject +
", isListContainer=" + isListContainer +

View File

@ -1015,6 +1015,7 @@ public class DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "File");
typeMapping.put("file", "File");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "URI");
//typeMapping.put("BigDecimal", "BigDecimal"); //TODO need the mapping?
@ -1025,6 +1026,7 @@ public class DefaultCodegen implements CodegenConfig {
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");
@ -1233,6 +1235,8 @@ public class DefaultCodegen implements CodegenConfig {
codegenParameter.example = "2013-10-20T19:20:30+01:00";
} else if (Boolean.TRUE.equals(codegenParameter.isUuid)) {
codegenParameter.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
} else if (Boolean.TRUE.equals(codegenParameter.isUri)) {
codegenParameter.example = "https://openapi-generator.tech";
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
codegenParameter.example = codegenParameter.paramName + "_example";
} else if (Boolean.TRUE.equals(codegenParameter.isFreeFormObject)) {
@ -1512,6 +1516,8 @@ public class DefaultCodegen implements CodegenConfig {
return "array";
} else if (ModelUtils.isUUIDSchema(schema)) {
return "UUID";
} else if (ModelUtils.isURISchema(schema)) {
return "URI";
} else if (ModelUtils.isStringSchema(schema)) {
return "string";
} else if (ModelUtils.isFreeFormObject(schema)) {
@ -2038,6 +2044,9 @@ public class DefaultCodegen implements CodegenConfig {
// keep isString to true to make it backward compatible
property.isString = true;
property.isUuid = true;
} else if (ModelUtils.isURISchema(p)) {
property.isString = true; // for backward compatibility
property.isUri = true;
} else if (ModelUtils.isEmailSchema(p)) {
property.isString = true;
property.isEmail = true;

View File

@ -277,6 +277,8 @@ public class ExampleGenerator {
return mp;
} else if (ModelUtils.isUUIDSchema(property)) {
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
} else if (ModelUtils.isURISchema(property)) {
return "https://openapi-generator.tech";
} else if (ModelUtils.isStringSchema(property)) {
LOGGER.debug("String property");
String defaultValue = (String) property.getDefault();

View File

@ -193,6 +193,8 @@ public class XmlExampleGenerator {
return "********";
} else if (ModelUtils.isUUIDSchema(schema)) {
return "046b6c7f-0b8a-43b9-b35d-6489e6daee91";
} else if (ModelUtils.isURISchema(schema)) {
return "https://openapi-generator.tech";
// do these last in case the specific types above are derived from these classes
} else if (ModelUtils.isStringSchema(schema)) {
return "aeiou";

View File

@ -140,6 +140,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
typeMapping.put("object", "Swagger.Object");
typeMapping.put("number", "Swagger.Number");
typeMapping.put("UUID", "Swagger.UString");
typeMapping.put("URI", "Swagger.UString");
typeMapping.put("file", "Swagger.Http_Content_Type");
typeMapping.put("binary", "Swagger.Binary");

View File

@ -185,6 +185,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
typeMapping.put("UUID", "Guid?");
typeMapping.put("URI", "string");
// nullable type
nullableType = new HashSet<String>(
@ -1087,6 +1088,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
codegenParameter.example = "2013-10-20T19:20:30+01:00";
} else if (Boolean.TRUE.equals(codegenParameter.isUuid)) {
codegenParameter.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
} else if (Boolean.TRUE.equals(codegenParameter.isUri)) {
codegenParameter.example = "https://openapi-generator.tech";
} else if (Boolean.TRUE.equals(codegenParameter.isString)) {
codegenParameter.example = codegenParameter.paramName + "_example";
}

View File

@ -71,6 +71,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
typeMapping.put("boolean", "BOOLEAN");
typeMapping.put("string", "STRING_32");
typeMapping.put("UUID", "UUID"); //
typeMapping.put("URI", "STRING"); //
typeMapping.put("date", "DATE");
typeMapping.put("DateTime", "DATE_TIME");
typeMapping.put("date-time", "DATE_TIME");

View File

@ -171,6 +171,7 @@ public abstract class AbstractFSharpCodegen extends DefaultCodegen implements Co
typeMapping.put("map", "IDictionary");
typeMapping.put("object", "obj");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
// nullable type
nullableType = new HashSet<String>(

View File

@ -98,6 +98,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
typeMapping.put("boolean", "bool");
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "time.Time");
typeMapping.put("password", "string");

View File

@ -82,6 +82,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
typeMapping.put("boolean", "Boolean");
typeMapping.put("string", "String");
typeMapping.put("UUID", "ID");
typeMapping.put("URI", "String");
typeMapping.put("date", "String");
typeMapping.put("DateTime", "String");
typeMapping.put("password", "String");

View File

@ -184,6 +184,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");

View File

@ -125,6 +125,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));

View File

@ -81,6 +81,7 @@ abstract public class AbstractRubyCodegen extends DefaultCodegen implements Code
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
}
@Override

View File

@ -123,6 +123,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
typeMapping.put("File", "any");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("Error", "Error");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue(this.modelPropertyNaming));

View File

@ -94,6 +94,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
typeMapping.put("number", "Double");
typeMapping.put("short", "Integer");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
// https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_reserved_words.htm
setReservedWordsLowerCase(

View File

@ -100,6 +100,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);

View File

@ -199,6 +199,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "binary");
typeMapping.put("binary", "binary");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
/**
* Additional Properties. These values can be passed to the templates and

View File

@ -152,6 +152,7 @@ public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("binary", "binary_t*");
typeMapping.put("ByteArray", "char");
typeMapping.put("UUID", "char");
typeMapping.put("URI", "char");
typeMapping.put("array", "list");
typeMapping.put("map", "list_t*");
typeMapping.put("date-time", "char");

View File

@ -95,6 +95,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("DateTime", "DateTime");
typeMapping.put("date", "DateTime");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);

View File

@ -100,6 +100,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
typeMapping.put("UUID", "Guid");
typeMapping.put("URI", "string");
setSupportNullable(Boolean.TRUE);
hideGenerationTimestamp = Boolean.TRUE;

View File

@ -93,6 +93,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
typeMapping.put("date", "inst?");
typeMapping.put("DateTime", "inst?");
typeMapping.put("UUID", "uuid?");
typeMapping.put("URI", "string?");
// But some type mappings are not really worth/meaningful to check for:
typeMapping.put("object", "any?"); // Like, everything is an object.

View File

@ -107,6 +107,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "std::string");
typeMapping.put("number", "double");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>();

View File

@ -88,6 +88,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// come out of the box and will need to be sorted out (at least imply
// modifications on multiple templates)
typeMapping.put("UUID", "QString");
typeMapping.put("URI", "QString");
typeMapping.put("file", "QIODevice");
typeMapping.put("binary", "QIODevice");
importMapping = new HashMap<String, String>();

View File

@ -146,6 +146,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "utility::string_t");
typeMapping.put("number", "double");
typeMapping.put("UUID", "utility::string_t");
typeMapping.put("URI", "utility::string_t");
typeMapping.put("ByteArray", "utility::string_t");
super.importMapping = new HashMap<String, String>();

View File

@ -89,6 +89,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
typeMapping.put("binary", "restbed::Bytes");
typeMapping.put("number", "double");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
typeMapping.put("ByteArray", "std::string");
super.importMapping = new HashMap<String, String>();

View File

@ -102,6 +102,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
typeMapping.put("DateTime", "std::string");
typeMapping.put("Date", "std::string");
typeMapping.put("UUID", "std::string");
typeMapping.put("URI", "std::string");
importMapping = new HashMap<String, String>();

View File

@ -115,6 +115,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("File", "MultipartFile");
typeMapping.put("binary", "MultipartFile");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("ByteArray", "String");
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));

View File

@ -87,6 +87,7 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
protoTypeMapping.put("file", "bytes");
protoTypeMapping.put("binary", "bytes");
protoTypeMapping.put("UUID", "string");
protoTypeMapping.put("URI", "string");
protoTypeMapping.put("ByteArray", "bytes");
}

View File

@ -175,6 +175,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "String");
typeMapping.put("ByteArray", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, "The main namespace to use for all classes. e.g. Yay.Pets"));
cliOptions.add(new CliOption("licenseHeader", "The license header to prepend to the top of all source files."));

View File

@ -138,6 +138,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "String");
typeMapping.put("binary", "String");
typeMapping.put("UUID", "Uuid");
typeMapping.put("URI", "String");
importMapping.clear();

View File

@ -95,6 +95,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary()");
typeMapping.put("byte", "binary()");
typeMapping.put("uuid", "binary()");
typeMapping.put("uri", "binary()");
typeMapping.put("password", "binary()");
cliOptions.clear();

View File

@ -98,6 +98,7 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary()");
typeMapping.put("byte", "binary()");
typeMapping.put("uuid", "binary()");
typeMapping.put("uri", "binary()");
typeMapping.put("password", "binary()");
cliOptions.clear();

View File

@ -102,6 +102,7 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("bytearray", "binary");
typeMapping.put("byte", "binary");
typeMapping.put("uuid", "binary");
typeMapping.put("uri", "binary");
typeMapping.put("password", "binary");
cliOptions.clear();

View File

@ -74,6 +74,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("object", "Object");
typeMapping.put("file", "File");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("binary", "File");
importMapping = new HashMap<String, String>();

View File

@ -227,6 +227,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
// lib
typeMapping.put("string", "Text");
typeMapping.put("UUID", "Text");
typeMapping.put("URI", "Text");
typeMapping.put("any", "A.Value");
typeMapping.put("set", "Set.Set");
// newtype

View File

@ -173,6 +173,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("number", "Double");
typeMapping.put("any", "Value");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "Text");
typeMapping.put("ByteArray", "Text");
typeMapping.put("object", "Value");

View File

@ -156,6 +156,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
typeMapping.put("binary", "File");
typeMapping.put("file", "File");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
importMapping.clear();

View File

@ -95,6 +95,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
defaultIncludes = new HashSet<String>(languageSpecificPrimitives);
outputFolder = "generated-code/javascript-flowtyped";

View File

@ -108,6 +108,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "boolean");
typeMapping.put("string", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "string");
typeMapping.put("password", "string");

View File

@ -117,6 +117,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
"binary",
"file",
"UUID",
"URI",
"BigDecimal",
"mixed",
"number",
@ -148,6 +149,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "MEDIUMBLOB");
typeMapping.put("file", "MEDIUMBLOB");
typeMapping.put("UUID", "TEXT");
typeMapping.put("URI", "TEXT");
typeMapping.put("BigDecimal", "DECIMAL");
embeddedTemplateDir = templateDir = "mysql-schema";

View File

@ -134,6 +134,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("bytearray", "NSData");
typeMapping.put("byte", "NSData");
typeMapping.put("uuid", "NSString");
typeMapping.put("uri", "NSString");
typeMapping.put("password", "NSString");
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm

View File

@ -111,6 +111,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("file", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.clear();
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("OpenAPIClient"));

View File

@ -173,6 +173,7 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
cliOptions.add(new CliOption(COMPOSER_VENDOR_NAME, "The vendor name used in the composer package name." +
" The template uses {{composerVendorName}}/{{composerProjectName}} for the composer package name. e.g. yaypets"));

View File

@ -93,6 +93,7 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
typeMapping.put("object", "object");
typeMapping.put("file", "file");
typeMapping.put("UUID", "str");
typeMapping.put("URI", "str");
typeMapping.put("byte", "bytearray");
typeMapping.put("ByteArray", "bytearray");

View File

@ -113,6 +113,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("ByteArray", "str");
// map uuid to string for the time being
typeMapping.put("UUID", "str");
typeMapping.put("URI", "str");
// from https://docs.python.org/3/reference/lexical_analysis.html#keywords
setReservedWordsLowerCase(

View File

@ -96,6 +96,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "character");
typeMapping.put("string", "character");
typeMapping.put("UUID", "character");
typeMapping.put("URI", "character");
typeMapping.put("date", "character");
typeMapping.put("DateTime", "character");
typeMapping.put("password", "character");

View File

@ -116,6 +116,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("boolean", "bool");
typeMapping.put("string", "String");
typeMapping.put("UUID", "String");
typeMapping.put("URI", "String");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "String");
typeMapping.put("password", "String");

View File

@ -154,6 +154,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("double", "f64");
typeMapping.put("string", "String");
typeMapping.put("UUID", uuidType);
typeMapping.put("URI", "String");
typeMapping.put("byte", "u8");
typeMapping.put("ByteArray", bytesType);
typeMapping.put("binary", bytesType);

View File

@ -154,6 +154,7 @@ public class ScalaFinchServerCodegen extends DefaultCodegen implements CodegenCo
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");

View File

@ -101,6 +101,7 @@ public class ScalatraServerCodegen extends AbstractScalaCodegen implements Codeg
importMapping = new HashMap<String, String>();
importMapping.put("BigDecimal", "java.math.BigDecimal");
importMapping.put("UUID", "java.util.UUID");
importMapping.put("URI", "java.net.URI");
importMapping.put("File", "java.io.File");
importMapping.put("Date", "java.util.Date");
importMapping.put("Timestamp", "java.sql.Timestamp");

View File

@ -151,6 +151,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "Data");
typeMapping.put("ByteArray", "Data");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<>();

View File

@ -197,6 +197,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("binary", "URL");
typeMapping.put("ByteArray", "Data");
typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<>();

View File

@ -169,6 +169,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("binary", "NSURL");
typeMapping.put("ByteArray", "NSData");
typeMapping.put("UUID", "NSUUID");
typeMapping.put("URI", "String");
importMapping = new HashMap<String, String>();

View File

@ -42,6 +42,7 @@ import java.util.stream.Collectors;
public class ModelUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(ModelUtils.class);
private static final String URI_FORMAT = "uri";
private static boolean generateAliasAsModel = false;
public static void setGenerateAliasAsModel(boolean value) {
@ -500,6 +501,14 @@ public class ModelUtils {
return false;
}
public static boolean isURISchema(Schema schema) {
if (SchemaTypeUtil.STRING_TYPE.equals(schema.getType())
&& URI_FORMAT.equals(schema.getFormat())) { // format: uri
return true;
}
return false;
}
public static boolean isEmailSchema(Schema schema) {
if (schema instanceof EmailSchema) {
return true;