forked from loafle/openapi-generator-original
also build for 2.10
This commit is contained in:
parent
59d74a83af
commit
55ce19a233
19
build.sbt
19
build.sbt
@ -13,17 +13,30 @@ javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation")
|
||||
|
||||
scalacOptions ++= Seq("-optimize", "-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8")
|
||||
|
||||
crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2")
|
||||
crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2", "2.10.0")
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"org.fusesource.scalate" % "scalate-wikitext_2.9" % "1.6.1",
|
||||
"org.fusesource.scalate" % "scalate-page_2.9" % "1.6.1",
|
||||
"org.json4s" %% "json4s-jackson" % "3.1.0",
|
||||
"commons-io" % "commons-io" % "2.3",
|
||||
"junit" % "junit" % "4.11" % "test",
|
||||
"org.scalatest" %% "scalatest" % "1.9.1" % "test"
|
||||
)
|
||||
|
||||
libraryDependencies <+= scalaVersion {
|
||||
case v if v.startsWith("2.9") =>
|
||||
"org.fusesource.scalate" % "scalate-wikitext_2.9" % "1.6.1"
|
||||
case v if v.startsWith("2.10") =>
|
||||
"org.fusesource.scalate" %% "scalate-wikitext" % "1.6.1"
|
||||
}
|
||||
|
||||
|
||||
libraryDependencies <+= scalaVersion {
|
||||
case v if v.startsWith("2.9") =>
|
||||
"org.fusesource.scalate" % "scalate-page_2.9" % "1.6.1"
|
||||
case v if v.startsWith("2.10") =>
|
||||
"org.fusesource.scalate" %% "scalate-page" % "1.6.1"
|
||||
}
|
||||
|
||||
packageOptions <+= (name, version, organization) map {
|
||||
(title, version, vendor) =>
|
||||
Package.ManifestAttributes(
|
||||
|
@ -238,7 +238,7 @@ public class ApiInvoker extends EventDispatcher
|
||||
var qualifiedClassName:String=objDescriptor.@name;
|
||||
qualifiedClassName=qualifiedClassName.replace("::",".");
|
||||
var className: String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1);
|
||||
className = className.charAt().toLowerCase() + className.substring(1);
|
||||
className = className().toLowerCase() + className.substring(1);
|
||||
writer.xml.setName(className);
|
||||
|
||||
for each(property in objDescriptor.elements("variable")){
|
||||
|
@ -31,7 +31,7 @@ internal class ApiUrlHelper {
|
||||
}
|
||||
|
||||
internal static function getProxyUrl(hostName: String, proxyPath: String): String{
|
||||
if (hostName.charAt(hostName.length - 1) == "/") //remove trailing slash
|
||||
if (hostName(hostName.length - 1) == "/") //remove trailing slash
|
||||
{
|
||||
hostName = hostName.substring(0, hostName.length - 1);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class ApiInvoker extends EventDispatcher
|
||||
var qualifiedClassName:String=objDescriptor.@name;
|
||||
qualifiedClassName=qualifiedClassName.replace("::",".");
|
||||
var className: String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(".") + 1);
|
||||
className = className.charAt().toLowerCase() + className.substring(1);
|
||||
className = className().toLowerCase() + className.substring(1);
|
||||
writer.xml.setName(className);
|
||||
|
||||
for each(property in objDescriptor.elements("variable")){
|
||||
|
@ -31,7 +31,7 @@ internal class ApiUrlHelper {
|
||||
}
|
||||
|
||||
internal static function getProxyUrl(hostName: String, proxyPath: String): String{
|
||||
if (hostName.charAt(hostName.length - 1) == "/") //remove trailing slash
|
||||
if (hostName(hostName.length - 1) == "/") //remove trailing slash
|
||||
{
|
||||
hostName = hostName.substring(0, hostName.length - 1);
|
||||
}
|
||||
|
@ -70,13 +70,13 @@ class BasicObjcGenerator extends BasicGenerator {
|
||||
defaultIncludes ++
|
||||
languageSpecificPrimitives
|
||||
).toSet.contains(name) match {
|
||||
case true => name.charAt(0).toUpperCase + name.substring(1)
|
||||
case _ => "NIK" + name.charAt(0).toUpperCase + name.substring(1)
|
||||
case true => name(0).toUpper + name.substring(1)
|
||||
case _ => "NIK" + name(0).toUpper + name.substring(1)
|
||||
}
|
||||
}
|
||||
|
||||
// naming for the apis
|
||||
override def toApiName(name: String) = "NIK" + name.charAt(0).toUpperCase + name.substring(1) + "Api"
|
||||
override def toApiName(name: String) = "NIK" + name(0).toUpper + name.substring(1) + "Api"
|
||||
|
||||
// location of templates
|
||||
override def templateDir = "src/main/resources/objc"
|
||||
|
@ -27,7 +27,7 @@ object BasicRubyGenerator extends BasicRubyGenerator {
|
||||
class BasicRubyGenerator extends BasicGenerator {
|
||||
|
||||
override def toApiName(name: String) = {
|
||||
name.charAt(0).toUpperCase + name.substring(1) + "_api"
|
||||
name(0).toUpper + name.substring(1) + "_api"
|
||||
}
|
||||
|
||||
override def apiPackage = Some("lib")
|
||||
@ -68,14 +68,14 @@ class BasicRubyGenerator extends BasicGenerator {
|
||||
def toUnderscore(name: String): String = {
|
||||
val sb = new StringBuilder
|
||||
for ((char) <- super.toVarName(name)) {
|
||||
if (char.isUpperCase) sb.append("_").append(char.toLowerCase)
|
||||
if (char.isUpper) sb.append("_").append(char.toLower)
|
||||
else sb.append(char)
|
||||
}
|
||||
sb.toString
|
||||
}
|
||||
|
||||
override def toDeclaration(obj: ModelProperty) = {
|
||||
var datatype = obj.`type`.charAt(0).toUpperCase + obj.`type`.substring(1)
|
||||
var datatype = obj.`type`(0).toUpper + obj.`type`.substring(1)
|
||||
|
||||
datatype match {
|
||||
case "Array" => datatype = "List"
|
||||
|
@ -183,7 +183,7 @@ class Codegen(config: CodegenConfig) {
|
||||
var output = engine.layout(config.templateDir + File.separator + templateFile, template, data.toMap)
|
||||
|
||||
// a shutdown method will be added to scalate in an upcoming release
|
||||
engine.compiler.asInstanceOf[ScalaCompiler].compiler.askShutdown
|
||||
engine.compiler.shutdown
|
||||
output
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ class Codegen(config: CodegenConfig) {
|
||||
paramList.size match {
|
||||
case 0 =>
|
||||
case _ => {
|
||||
sp.first.asInstanceOf[HashMap[String, String]] -= "secondaryParam"
|
||||
sp.head.asInstanceOf[HashMap[String, String]] -= "secondaryParam"
|
||||
sp.last.asInstanceOf[HashMap[String, String]] -= "hasMore"
|
||||
}
|
||||
}
|
||||
@ -544,7 +544,7 @@ class Codegen(config: CodegenConfig) {
|
||||
}
|
||||
})
|
||||
//a shutdown method will be added to scalate in an upcoming release
|
||||
engine.compiler.asInstanceOf[ScalaCompiler].compiler.askShutdown
|
||||
engine.compiler.shutdown()
|
||||
}
|
||||
|
||||
protected def isListType(dt: String) = isCollectionType(dt, "List") || isCollectionType(dt, "Array")
|
||||
|
@ -34,12 +34,12 @@ trait PathUtil {
|
||||
}
|
||||
|
||||
def toModelName(name: String) = {
|
||||
name.charAt(0).toUpperCase + name.substring(1)
|
||||
name(0).toUpper + name.substring(1)
|
||||
}
|
||||
|
||||
def toApiName(name: String) = {
|
||||
name.replaceAll("\\{","").replaceAll("\\}", "") match {
|
||||
case s: String if(s.length > 0) => s.charAt(0).toUpperCase + s.substring(1) + "Api"
|
||||
case s: String if(s.length > 0) => s(0).toUpper + s.substring(1) + "Api"
|
||||
case _ => "Api"
|
||||
}
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ abstract class CodegenConfig {
|
||||
case "boolean" => "is"
|
||||
case _ => "get"
|
||||
}
|
||||
base + name.charAt(0).toUpperCase + name.substring(1)
|
||||
base + name(0).toUpper + name.substring(1)
|
||||
}
|
||||
|
||||
def toSetter(name: String, datatype: String) = {
|
||||
val base = datatype match {
|
||||
case _ => "set"
|
||||
}
|
||||
base + name.charAt(0).toUpperCase + name.substring(1)
|
||||
base + name(0).toUpper + name.substring(1)
|
||||
}
|
||||
|
||||
def toVarName(name: String): String = {
|
||||
|
@ -110,7 +110,7 @@ object CoreUtils {
|
||||
modelObjects += name -> m
|
||||
|
||||
// extract all base model names, strip away Containers like List[] and primitives
|
||||
val baseNames = (for (modelName <- (modelNames.toList -- primitives))
|
||||
val baseNames = (for (modelName <- (modelNames.toList filterNot primitives.contains))
|
||||
yield (extractBasePartFromType(modelName))).toSet
|
||||
|
||||
// get complex models from base
|
||||
|
Loading…
x
Reference in New Issue
Block a user