fixed return type inside containers

This commit is contained in:
Tony Tam 2012-09-12 09:52:14 -07:00
parent de1ef1dde3
commit 374c68d8da

View File

@ -335,9 +335,9 @@ class Codegen(config: CodegenConfig) {
case n: Int => { case n: Int => {
val ComplexTypeMatcher = ".*\\[(.*)\\].*".r val ComplexTypeMatcher = ".*\\[(.*)\\].*".r
val ComplexTypeMatcher(basePart) = op.responseClass val ComplexTypeMatcher(basePart) = op.responseClass
properties += "returnType" -> config.processResponseDeclaration(op.responseClass) properties += "returnType" -> config.processResponseDeclaration(op.responseClass.replaceAll(basePart, config.processResponseClass(basePart).get))
properties += "returnContainer" -> (op.responseClass.substring(0, n)) properties += "returnContainer" -> (op.responseClass.substring(0, n))
properties += "returnBaseType" -> Some(basePart) properties += "returnBaseType" -> Some(config.processResponseClass(basePart))
properties += "returnTypeIsPrimitive" -> { properties += "returnTypeIsPrimitive" -> {
(config.languageSpecificPrimitives.contains(basePart) || primitives.contains(basePart)) match { (config.languageSpecificPrimitives.contains(basePart) || primitives.contains(basePart)) match {
case true => Some("true") case true => Some("true")
@ -369,8 +369,12 @@ class Codegen(config: CodegenConfig) {
if (propertyDocSchema.items != null) { if (propertyDocSchema.items != null) {
// import the container // import the container
imports += Map("import" -> dt) imports += Map("import" -> dt)
if (propertyDocSchema.items.ref != null) baseType = propertyDocSchema.items.ref if (propertyDocSchema.items.ref != null) {
else if (propertyDocSchema.items.getType != null) baseType = propertyDocSchema.items.getType baseType = propertyDocSchema.items.ref
}
else if (propertyDocSchema.items.getType != null) {
baseType = propertyDocSchema.items.getType
}
} }
baseType = config.typeMapping.contains(baseType) match { baseType = config.typeMapping.contains(baseType) match {
case true => config.typeMapping(baseType) case true => config.typeMapping(baseType)
@ -412,7 +416,6 @@ class Codegen(config: CodegenConfig) {
"isContainer" -> isContainer, "isContainer" -> isContainer,
"isNotContainer" -> isNotContainer, "isNotContainer" -> isNotContainer,
"hasMore" -> "true") "hasMore" -> "true")
(config.languageSpecificPrimitives.contains(baseType) || primitives.contains(baseType)) match { (config.languageSpecificPrimitives.contains(baseType) || primitives.contains(baseType)) match {
case true => properties += "isPrimitiveType" -> "true" case true => properties += "isPrimitiveType" -> "true"
case _ => properties += "complexType" -> baseType case _ => properties += "complexType" -> baseType