forked from loafle/openapi-generator-original
added support for swagger 1.2 spec
This commit is contained in:
parent
a31780e08f
commit
885cd36165
@ -5,9 +5,9 @@ organization := "com.wordnik"
|
|||||||
|
|
||||||
name := "swagger-codegen"
|
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")
|
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")
|
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
|
publishMavenStyle := true
|
||||||
|
|
||||||
publishArtifact in Test := false
|
publishArtifact in Test := false
|
||||||
|
@ -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
|
val apiReferences = doc.apis
|
||||||
if (apiReferences == null)
|
if (apiReferences == null)
|
||||||
|
@ -31,9 +31,10 @@ object ApiExtractor extends RemoteUrl {
|
|||||||
implicit val formats = SwaggerSerializers.formats
|
implicit val formats = SwaggerSerializers.formats
|
||||||
|
|
||||||
def fetchApiListings(basePath: String, apis: List[ApiListingReference], apiKey: Option[String] = None): List[ApiListing] = {
|
def fetchApiListings(basePath: String, apis: List[ApiListingReference], apiKey: Option[String] = None): List[ApiListing] = {
|
||||||
|
println("looking at base path " + basePath)
|
||||||
(for (api <- apis) yield {
|
(for (api <- apis) yield {
|
||||||
try{
|
try{
|
||||||
val json = basePath.startsWith("http") match {
|
val json = (basePath.startsWith("http")) match {
|
||||||
case true => {
|
case true => {
|
||||||
println("calling: " + ((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json")))
|
println("calling: " + ((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json")))
|
||||||
urlToString((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json"))
|
urlToString((basePath + api.path + apiKey.getOrElse("")).replaceAll(".\\{format\\}", ".json"))
|
||||||
|
@ -89,7 +89,7 @@ object SwaggerSerializers {
|
|||||||
""
|
""
|
||||||
}),
|
}),
|
||||||
(json \ "basePath").extractOrElse({
|
(json \ "basePath").extractOrElse({
|
||||||
!!(json, RESOURCE_LISTING, "basePath", "missing required field", ERROR)
|
!!(json, RESOURCE_LISTING, "basePath", "missing deprecated field", WARNING)
|
||||||
""
|
""
|
||||||
}),
|
}),
|
||||||
(json \ "apis").extract[List[ApiListingReference]]
|
(json \ "apis").extract[List[ApiListingReference]]
|
||||||
@ -177,10 +177,12 @@ object SwaggerSerializers {
|
|||||||
case json =>
|
case json =>
|
||||||
implicit val fmts: Formats = formats
|
implicit val fmts: Formats = formats
|
||||||
Operation(
|
Operation(
|
||||||
(json \ "httpMethod").extractOrElse({
|
(json \ "httpMethod").extractOrElse(
|
||||||
!!(json, OPERATION, "httpMethod", "missing required field", ERROR)
|
(json \ "method").extractOrElse({
|
||||||
|
!!(json, OPERATION, "method", "missing required field", ERROR)
|
||||||
""
|
""
|
||||||
}),
|
})
|
||||||
|
),
|
||||||
(json \ "summary").extract[String],
|
(json \ "summary").extract[String],
|
||||||
(json \ "notes").extractOrElse(""),
|
(json \ "notes").extractOrElse(""),
|
||||||
(json \ "responseClass").extractOrElse({
|
(json \ "responseClass").extractOrElse({
|
||||||
@ -198,7 +200,7 @@ object SwaggerSerializers {
|
|||||||
}, {
|
}, {
|
||||||
case x: Operation =>
|
case x: Operation =>
|
||||||
implicit val fmts = formats
|
implicit val fmts = formats
|
||||||
("httpMethod" -> x.httpMethod) ~
|
("method" -> x.httpMethod) ~
|
||||||
("summary" -> x.summary) ~
|
("summary" -> x.summary) ~
|
||||||
("notes" -> x.notes) ~
|
("notes" -> x.notes) ~
|
||||||
("responseClass" -> x.responseClass) ~
|
("responseClass" -> x.responseClass) ~
|
||||||
|
Loading…
x
Reference in New Issue
Block a user