Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Groovy samples to oas3 #6435

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/groovy-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 0 additions & 31 deletions bin/openapi3/groovy-petstore.sh

This file was deleted.

10 changes: 10 additions & 0 deletions bin/windows/groovy-petstore.bat
Original file line number Diff line number Diff line change
@@ -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%
8 changes: 5 additions & 3 deletions samples/client/petstore/groovy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 )

}

Expand Down Expand Up @@ -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
Expand All @@ -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 )

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}