diff --git a/bin/groovy-petstore.sh b/bin/groovy-petstore.sh index 1a9db858a3c7..e5e5f688eb33 100755 --- a/bin/groovy-petstore.sh +++ b/bin/groovy-petstore.sh @@ -27,5 +27,5 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/Groovy/ -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g groovy -o samples/client/petstore/groovy --additional-properties hideGenerationTimestamp=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/Groovy/ -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g groovy -o samples/client/petstore/groovy --additional-properties hideGenerationTimestamp=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/groovy-petstore.sh b/bin/openapi3/groovy-petstore.sh deleted file mode 100755 index c0c1ddda0518..000000000000 --- a/bin/openapi3/groovy-petstore.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -SCRIPT="$0" -echo "# START SCRIPT: $SCRIPT" - -while [ -h "$SCRIPT" ] ; do - ls=`ls -ld "$SCRIPT"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - SCRIPT="$link" - else - SCRIPT=`dirname "$SCRIPT"`/"$link" - fi -done - -if [ ! -d "${APP_DIR}" ]; then - APP_DIR=`dirname "$SCRIPT"`/.. - APP_DIR=`cd "${APP_DIR}"; pwd` -fi - -executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar" - -if [ ! -f "$executable" ] -then - mvn clean package -fi - -# if you've executed sbt assembly previously it will use that instead. -export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g groovy -o samples/client/petstore/groovy --additional-properties hideGenerationTimestamp=true $@" -java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/groovy-petstore.bat b/bin/windows/groovy-petstore.bat new file mode 100644 index 000000000000..67be72e61342 --- /dev/null +++ b/bin/windows/groovy-petstore.bat @@ -0,0 +1,10 @@ +set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties +set ags=generate --artifact-id "groovy-petstore-client" -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g groovy -o samples\client\petstore\nim + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/samples/client/petstore/groovy/README.md b/samples/client/petstore/groovy/README.md index 10ee35ffb9d9..9764cb2f1fda 100644 --- a/samples/client/petstore/groovy/README.md +++ b/samples/client/petstore/groovy/README.md @@ -32,12 +32,14 @@ Then, run: ```groovy def apiInstance = new PetApi() -def body = new Pet() // Pet | Pet object that needs to be added to the store +def pet = new Pet() // Pet | Pet object that needs to be added to the store -apiInstance.addPet(body) +apiInstance.addPet(pet) { // on success - println it + def result = (Pet)it + println result + } { // on failure diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy index 60f3f7d45da1..d448cfd544ea 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy @@ -9,7 +9,7 @@ class PetApi { String versionPath = "" ApiUtils apiUtils = new ApiUtils(); - def addPet ( Pet body, Closure onSuccess, Closure onFailure) { + def addPet ( Pet pet, Closure onSuccess, Closure onFailure) { String resourcePath = "/pet" // params @@ -19,19 +19,19 @@ class PetApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (pet == null) { + throw new RuntimeException("missing required params pet") } contentType = 'application/json'; - bodyParams = body + bodyParams = pet apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, "POST", "", - null ) + Pet.class ) } @@ -140,7 +140,7 @@ class PetApi { } - def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { + def updatePet ( Pet pet, Closure onSuccess, Closure onFailure) { String resourcePath = "/pet" // params @@ -150,19 +150,19 @@ class PetApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (pet == null) { + throw new RuntimeException("missing required params pet") } contentType = 'application/json'; - bodyParams = body + bodyParams = pet apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, "PUT", "", - null ) + Pet.class ) } diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy index 8e7a0ee9d279..319a6ddcaf88 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy @@ -76,7 +76,7 @@ class StoreApi { } - def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { + def placeOrder ( Order order, Closure onSuccess, Closure onFailure) { String resourcePath = "/store/order" // params @@ -86,14 +86,14 @@ class StoreApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (order == null) { + throw new RuntimeException("missing required params order") } contentType = 'application/json'; - bodyParams = body + bodyParams = order apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy index 8cc839868089..82be73e27bcb 100644 --- a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy @@ -9,7 +9,7 @@ class UserApi { String versionPath = "" ApiUtils apiUtils = new ApiUtils(); - def createUser ( User body, Closure onSuccess, Closure onFailure) { + def createUser ( User user, Closure onSuccess, Closure onFailure) { String resourcePath = "/user" // params @@ -19,14 +19,14 @@ class UserApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (user == null) { + throw new RuntimeException("missing required params user") } contentType = 'application/json'; - bodyParams = body + bodyParams = user apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -35,7 +35,7 @@ class UserApi { } - def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { + def createUsersWithArrayInput ( List user, Closure onSuccess, Closure onFailure) { String resourcePath = "/user/createWithArray" // params @@ -45,14 +45,14 @@ class UserApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (user == null) { + throw new RuntimeException("missing required params user") } contentType = 'application/json'; - bodyParams = body + bodyParams = user apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -61,7 +61,7 @@ class UserApi { } - def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { + def createUsersWithListInput ( List user, Closure onSuccess, Closure onFailure) { String resourcePath = "/user/createWithList" // params @@ -71,14 +71,14 @@ class UserApi { def contentType // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (user == null) { + throw new RuntimeException("missing required params user") } contentType = 'application/json'; - bodyParams = body + bodyParams = user apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, @@ -189,7 +189,7 @@ class UserApi { } - def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { + def updateUser ( String username, User user, Closure onSuccess, Closure onFailure) { String resourcePath = "/user/${username}" // params @@ -203,14 +203,14 @@ class UserApi { throw new RuntimeException("missing required params username") } // verify required params are set - if (body == null) { - throw new RuntimeException("missing required params body") + if (user == null) { + throw new RuntimeException("missing required params user") } contentType = 'application/json'; - bodyParams = body + bodyParams = user apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType, diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject.groovy new file mode 100644 index 000000000000..820695239c39 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject.groovy @@ -0,0 +1,13 @@ +package org.openapitools.model; + +import groovy.transform.Canonical +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@Canonical +class InlineObject { + /* Updated name of the pet */ + String name + /* Updated status of the pet */ + String status +} diff --git a/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject1.groovy b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject1.groovy new file mode 100644 index 000000000000..e60a96d81d33 --- /dev/null +++ b/samples/client/petstore/groovy/src/main/groovy/org/openapitools/model/InlineObject1.groovy @@ -0,0 +1,13 @@ +package org.openapitools.model; + +import groovy.transform.Canonical +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@Canonical +class InlineObject1 { + /* Additional data to pass to server */ + String additionalMetadata + /* file to upload */ + File file +}