forked from loafle/openapi-generator-original
Migrate Groovy samples to oas3 (#6435)
* migrate groovy samples to oas3 * update samples
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
10
bin/windows/groovy-petstore.bat
Normal file
10
bin/windows/groovy-petstore.bat
Normal file
@@ -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%
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<User> body, Closure onSuccess, Closure onFailure) {
|
||||
def createUsersWithArrayInput ( List<User> 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<User> body, Closure onSuccess, Closure onFailure) {
|
||||
def createUsersWithListInput ( List<User> 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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user