From 9d1f0bf56842dc4ae32cad90a4e7642b0b6f3c50 Mon Sep 17 00:00:00 2001 From: "Mark H. Butler" Date: Wed, 8 Oct 2014 08:19:08 -0700 Subject: [PATCH 1/3] Adding ignore for gedit files (Linux) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b17bf46aa108..ae4c9e53c36d 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ target .lib atlassian-ide-plugin.xml .DS_Store +*~ From 6f30a6d65a73391ea038429d204f43ad4b7b6238 Mon Sep 17 00:00:00 2001 From: "Mark H. Butler" Date: Wed, 8 Oct 2014 08:20:02 -0700 Subject: [PATCH 2/3] Modifying the pom.xml template because it defaults to building with Scala 2.9.1, but that is broken because BeanProperty moved, so instead use 2.10 as the default but add the option of using Scala 2.11 --- samples/client/petstore/scala/pom.xml | 23 ++- .../com/wordnik/petstore/api/PetApi.scala | 101 +++++----- .../com/wordnik/petstore/api/UserApi.scala | 174 +++++++++--------- .../scala/src/test/scala/PetApiTest.scala | 6 +- src/main/resources/scala/pom.mustache | 23 ++- 5 files changed, 171 insertions(+), 156 deletions(-) diff --git a/samples/client/petstore/scala/pom.xml b/samples/client/petstore/scala/pom.xml index bb7b19f64c19..fdd9eae1ba3d 100644 --- a/samples/client/petstore/scala/pom.xml +++ b/samples/client/petstore/scala/pom.xml @@ -188,25 +188,34 @@ + + scala_2.11 + + 2.11.2 + 2.11 + 1.3.10 + 2.2.2 + + scala_2.10 + + true + 2.10.3 2.10 - 1.3.2 + 1.3.10 2.1.2 scala_2.9.1 - - true - 2.9.1-1 2.9.1 - 1.1.0 - 1.6.1 + 1.3.1 + 1.9.2 @@ -215,7 +224,7 @@ 4.8.1 1.0.0 4.8.1 - 3.1.5 + 3.2.0 diff --git a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala index 0ae8819a7065..edef25d8e8f9 100644 --- a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala +++ b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala @@ -15,6 +15,34 @@ class PetApi { def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value + def deletePet (petId: String) = { + // create path and map variables + val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) + + + + val contentType = { + "application/json"} + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(petId).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } def getPetById (petId: Long) : Option[Pet]= { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -44,34 +72,6 @@ class PetApi { case ex: ApiException => throw ex } } - def deletePet (petId: String) = { - // create path and map variables - val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) - - - - val contentType = { - "application/json"} - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(petId).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } def partialUpdate (petId: String, body: Pet) : Option[List[Pet]]= { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -132,30 +132,6 @@ class PetApi { case ex: ApiException => throw ex } } - def uploadFile (additionalMetadata: String, body: File) = { - // create path and map variables - val path = "/pet/uploadImage".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } def addPet (body: Pet) = { // create path and map variables val path = "/pet".replaceAll("\\{format\\}","json") @@ -270,5 +246,26 @@ class PetApi { case ex: ApiException => throw ex } } + def uploadFile (additionalMetadata: String, file: File) = { + // create path and map variables + val path = "/pet/uploadImage".replaceAll("\\{format\\}","json") + + val contentType = { + "application/json"} + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, None, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } } diff --git a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala index bfeece060ef1..c9d82ab24208 100644 --- a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala +++ b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala @@ -15,6 +15,93 @@ class UserApi { def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value + def createUser (body: User) = { + // create path and map variables + val path = "/user".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + def createUsersWithArrayInput (body: List[User]) = { + // create path and map variables + val path = "/user/createWithArray".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + def createUsersWithListInput (body: List[User]) = { + // create path and map variables + val path = "/user/createWithList".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } def updateUser (username: String, body: User) = { // create path and map variables val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) @@ -153,92 +240,5 @@ class UserApi { case ex: ApiException => throw ex } } - def createUser (body: User) = { - // create path and map variables - val path = "/user".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - def createUsersWithArrayInput (body: List[User]) = { - // create path and map variables - val path = "/user/createWithArray".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - def createUsersWithListInput (body: List[User]) = { - // create path and map variables - val path = "/user/createWithList".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } } diff --git a/samples/client/petstore/scala/src/test/scala/PetApiTest.scala b/samples/client/petstore/scala/src/test/scala/PetApiTest.scala index adae715b4623..c06a2072998a 100644 --- a/samples/client/petstore/scala/src/test/scala/PetApiTest.scala +++ b/samples/client/petstore/scala/src/test/scala/PetApiTest.scala @@ -30,7 +30,7 @@ class PetApiTest extends FlatSpec with Matchers { Category(1, "sold"), "dragon", (for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList, - (for (i <- (1 to 5)) yield Tag(i, "tag-" + i)).toList, + (for (i <- (1 to 5)) yield com.wordnik.petstore.model.Tag(i, "tag-" + i)).toList, "lost" ) @@ -55,7 +55,7 @@ class PetApiTest extends FlatSpec with Matchers { Category(1, "sold"), "programmer", (for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList, - (for (i <- (1 to 5)) yield Tag(i, "tag-" + i)).toList, + (for (i <- (1 to 5)) yield com.wordnik.petstore.model.Tag(i, "tag-" + i)).toList, "confused" ) @@ -101,4 +101,4 @@ class PetApiTest extends FlatSpec with Matchers { case None => fail("didn't find pets by tag") } } -} \ No newline at end of file +} diff --git a/src/main/resources/scala/pom.mustache b/src/main/resources/scala/pom.mustache index 4cb2c261fad5..d5ad2d05a094 100644 --- a/src/main/resources/scala/pom.mustache +++ b/src/main/resources/scala/pom.mustache @@ -188,25 +188,34 @@ + + scala_2.11 + + 2.11.2 + 2.11 + 1.3.10 + 2.2.2 + + scala_2.10 + + true + 2.10.3 2.10 - 1.3.2 + 1.3.10 2.1.2 scala_2.9.1 - - true - 2.9.1-1 2.9.1 - 1.1.0 - 1.6.1 + 1.3.1 + 1.9.2 @@ -215,6 +224,6 @@ 4.8.1 1.0.0 4.8.1 - 3.1.5 + 3.2.0 From c8dac4a3cf90c0ab46ea55e7ccfbd492dcee9f8b Mon Sep 17 00:00:00 2001 From: "Mark H. Butler" Date: Wed, 8 Oct 2014 08:25:23 -0700 Subject: [PATCH 3/3] Reverting these files, they don't need to change --- .../com/wordnik/petstore/api/PetApi.scala | 101 +++++----- .../com/wordnik/petstore/api/UserApi.scala | 174 +++++++++--------- 2 files changed, 139 insertions(+), 136 deletions(-) diff --git a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala index edef25d8e8f9..0ae8819a7065 100644 --- a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala +++ b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/PetApi.scala @@ -15,34 +15,6 @@ class PetApi { def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value - def deletePet (petId: String) = { - // create path and map variables - val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) - - - - val contentType = { - "application/json"} - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(petId).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } def getPetById (petId: Long) : Option[Pet]= { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -72,6 +44,34 @@ class PetApi { case ex: ApiException => throw ex } } + def deletePet (petId: String) = { + // create path and map variables + val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) + + + + val contentType = { + "application/json"} + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(petId).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, None, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } def partialUpdate (petId: String, body: Pet) : Option[List[Pet]]= { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -132,6 +132,30 @@ class PetApi { case ex: ApiException => throw ex } } + def uploadFile (additionalMetadata: String, body: File) = { + // create path and map variables + val path = "/pet/uploadImage".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } def addPet (body: Pet) = { // create path and map variables val path = "/pet".replaceAll("\\{format\\}","json") @@ -246,26 +270,5 @@ class PetApi { case ex: ApiException => throw ex } } - def uploadFile (additionalMetadata: String, file: File) = { - // create path and map variables - val path = "/pet/uploadImage".replaceAll("\\{format\\}","json") - - val contentType = { - "application/json"} - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, None, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } } diff --git a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala index c9d82ab24208..bfeece060ef1 100644 --- a/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala +++ b/samples/client/petstore/scala/src/main/scala/com/wordnik/petstore/api/UserApi.scala @@ -15,93 +15,6 @@ class UserApi { def addHeader(key: String, value: String) = apiInvoker.defaultHeaders += key -> value - def createUser (body: User) = { - // create path and map variables - val path = "/user".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - def createUsersWithArrayInput (body: List[User]) = { - // create path and map variables - val path = "/user/createWithArray".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - def createUsersWithListInput (body: List[User]) = { - // create path and map variables - val path = "/user/createWithList".replaceAll("\\{format\\}","json") - - val contentType = { - if(body != null && body.isInstanceOf[File] ) - "multipart/form-data" - else "application/json" - } - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - - // verify required params are set - (List(body).filter(_ != null)).size match { - case 1 => // all required values set - case _ => throw new Exception("missing required params") - } - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } def updateUser (username: String, body: User) = { // create path and map variables val path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}",apiInvoker.escape(username)) @@ -240,5 +153,92 @@ class UserApi { case ex: ApiException => throw ex } } + def createUser (body: User) = { + // create path and map variables + val path = "/user".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + def createUsersWithArrayInput (body: List[User]) = { + // create path and map variables + val path = "/user/createWithArray".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } + def createUsersWithListInput (body: List[User]) = { + // create path and map variables + val path = "/user/createWithList".replaceAll("\\{format\\}","json") + + val contentType = { + if(body != null && body.isInstanceOf[File] ) + "multipart/form-data" + else "application/json" + } + + // query params + val queryParams = new HashMap[String, String] + val headerParams = new HashMap[String, String] + + // verify required params are set + (List(body).filter(_ != null)).size match { + case 1 => // all required values set + case _ => throw new Exception("missing required params") + } + try { + apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, body, headerParams.toMap, contentType) match { + case s: String => + case _ => None + } + } catch { + case ex: ApiException if ex.code == 404 => None + case ex: ApiException => throw ex + } + } }