merged pom + invoker changes, added correct mapping for list

This commit is contained in:
Tony Tam 2013-08-08 16:18:57 -07:00
parent d9d6cc1e76
commit 74543f75f9
3 changed files with 19 additions and 6 deletions

View File

@ -83,7 +83,7 @@ object ApiInvoker {
val client = getClient(host) val client = getClient(host)
val querystring = queryParams.filter(k => k._2 != null).map(k => (escapeString(k._1) + "=" + escapeString(k._2))).mkString("?", "&", "") val querystring = queryParams.filter(k => k._2 != null).map(k => (escapeString(k._1) + "=" + escapeString(k._2))).mkString("?", "&", "")
val builder = client.resource(host + path + querystring).`type`(contentType) val builder = client.resource(host + path + querystring).accept(contentType)
headerParams.map(p => builder.header(p._1, p._2)) headerParams.map(p => builder.header(p._1, p._2))
defaultHeaders.map(p => { defaultHeaders.map(p => {
@ -106,11 +106,13 @@ object ApiInvoker {
builder.post(classOf[ClientResponse], form) builder.post(classOf[ClientResponse], form)
} }
else { else {
builder.post(classOf[ClientResponse], serialize(body)) if(body == null) builder.post(classOf[ClientResponse], serialize(body))
else builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
} }
} }
case "PUT" => { case "PUT" => {
builder.put(classOf[ClientResponse], serialize(body)) if(body == null) builder.put(classOf[ClientResponse], null)
else builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
} }
case "DELETE" => { case "DELETE" => {
builder.delete(classOf[ClientResponse]) builder.delete(classOf[ClientResponse])

View File

@ -109,9 +109,9 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.scala-tools</groupId> <groupId>net.alchim31.maven</groupId>
<artifactId>maven-scala-plugin</artifactId> <artifactId>scala-maven-plugin</artifactId>
<version>2.15.2</version> <version>${scala-maven-plugin-version}</version>
<executions> <executions>
<execution> <execution>
<id>scala-compile-first</id> <id>scala-compile-first</id>
@ -196,5 +196,6 @@
<scala-test-version>1.6.1</scala-test-version> <scala-test-version>1.6.1</scala-test-version>
<junit-version>4.8.1</junit-version> <junit-version>4.8.1</junit-version>
<scala-test-version>1.6.1</scala-test-version> <scala-test-version>1.6.1</scala-test-version>
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
</properties> </properties>
</project> </project>

View File

@ -89,6 +89,16 @@ class BasicScalaGenerator extends BasicGenerator {
val e = "List[%s]" format toDeclaredType(inner) val e = "List[%s]" format toDeclaredType(inner)
(e, toDefaultValue(inner, obj)) (e, toDefaultValue(inner, obj))
} }
case "List" => {
val inner = {
obj.items match {
case Some(items) => items.ref.getOrElse(items.`type`)
case _ => throw new Exception("no inner type defined")
}
}
val e = "List[%s]" format toDeclaredType(inner)
(e, toDefaultValue(inner, obj))
}
case e: String => (toDeclaredType(e), toDefaultValue(e, obj)) case e: String => (toDeclaredType(e), toDefaultValue(e, obj))
} }
} }