diff --git a/build.sbt b/build.sbt index 5ed13c342a4..a71c47f373c 100644 --- a/build.sbt +++ b/build.sbt @@ -5,9 +5,9 @@ organization := "com.wordnik" name := "swagger-codegen" -version := "2.0.5" +version := "2.0.6" -scalaVersion := "2.9.2" +scalaVersion := "2.9.1" javacOptions ++= Seq("-target", "1.6", "-source", "1.6", "-Xlint:unchecked", "-Xlint:deprecation") @@ -55,6 +55,9 @@ publishTo <<= (version) { version: String => Some("Sonatype Nexus Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") } +publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository"))) + + publishMavenStyle := true publishArtifact in Test := false diff --git a/src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala b/src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala index e9ea12d0249..2f0e9ad5ea6 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/BasicGenerator.scala @@ -60,7 +60,13 @@ abstract class BasicGenerator extends CodegenConfig with PathUtil { } } - implicit val basePath = getBasePath(doc.basePath) + implicit val basePath = getBasePath(doc.basePath) match { + case "" => { + // use host + host + } + case e: String => e + } val apiReferences = doc.apis if (apiReferences == null) diff --git a/src/main/scala/com/wordnik/swagger/codegen/util/ApiExtractor.scala b/src/main/scala/com/wordnik/swagger/codegen/util/ApiExtractor.scala index a222bd467c9..aca4fd2b0b4 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/util/ApiExtractor.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/util/ApiExtractor.scala @@ -31,29 +31,30 @@ object ApiExtractor extends RemoteUrl { implicit val formats = SwaggerSerializers.formats def fetchApiListings(basePath: String, apis: List[ApiListingReference], apiKey: Option[String] = None): List[ApiListing] = { + println("looking at base path " + basePath) (for (api <- apis) yield { - try{ - val json = basePath.startsWith("http") match { - case true => { - println("calling: " + ((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json"))) - urlToString((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json")) - } - case false => Source.fromFile((basePath + api.path).replaceAll(".\\{format\\}", ".json")).mkString - } - Some(parse(json).extract[ApiListing]) + try{ + val json = (basePath.startsWith("http")) match { + case true => { + println("calling: " + ((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json"))) + urlToString((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json")) } - catch { - case e: java.io.FileNotFoundException => { - println("WARNING! Unable to read API " + basePath + api.path) - None - } - case e: Throwable => { - println("WARNING! Unable to read API " + basePath + api.path) - e.printStackTrace() - None - } - } - }).flatten.toList + case false => Source.fromFile((basePath + api.path).replaceAll(".\\{format\\}", ".json")).mkString + } + Some(parse(json).extract[ApiListing]) + } + catch { + case e: java.io.FileNotFoundException => { + println("WARNING! Unable to read API " + basePath + api.path) + None + } + case e: Throwable => { + println("WARNING! Unable to read API " + basePath + api.path) + e.printStackTrace() + None + } + } + }).flatten.toList } def extractApiOperations(basePath: String, references: List[ApiListingReference], apiKey: Option[String] = None) = { diff --git a/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala b/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala index c963e5df224..776ade83f72 100644 --- a/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala +++ b/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala @@ -89,7 +89,7 @@ object SwaggerSerializers { "" }), (json \ "basePath").extractOrElse({ - !!(json, RESOURCE_LISTING, "basePath", "missing required field", ERROR) + !!(json, RESOURCE_LISTING, "basePath", "missing deprecated field", WARNING) "" }), (json \ "apis").extract[List[ApiListingReference]] @@ -177,10 +177,12 @@ object SwaggerSerializers { case json => implicit val fmts: Formats = formats Operation( - (json \ "httpMethod").extractOrElse({ - !!(json, OPERATION, "httpMethod", "missing required field", ERROR) - "" - }), + (json \ "httpMethod").extractOrElse( + (json \ "method").extractOrElse({ + !!(json, OPERATION, "method", "missing required field", ERROR) + "" + }) + ), (json \ "summary").extract[String], (json \ "notes").extractOrElse(""), (json \ "responseClass").extractOrElse({ @@ -198,7 +200,7 @@ object SwaggerSerializers { }, { case x: Operation => implicit val fmts = formats - ("httpMethod" -> x.httpMethod) ~ + ("method" -> x.httpMethod) ~ ("summary" -> x.summary) ~ ("notes" -> x.notes) ~ ("responseClass" -> x.responseClass) ~