Skip to content

Commit ddcda1e

Browse files
authored
Migrate Groovy samples to oas3 (#6435)
* migrate groovy samples to oas3 * update samples
1 parent e6ba945 commit ddcda1e

File tree

9 files changed

+72
-65
lines changed

9 files changed

+72
-65
lines changed

bin/groovy-petstore.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
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 $@"
30+
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 $@"
3131
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/groovy-petstore.sh

-31
This file was deleted.

bin/windows/groovy-petstore.bat

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
8+
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
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

samples/client/petstore/groovy/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ Then, run:
3232

3333
```groovy
3434
def apiInstance = new PetApi()
35-
def body = new Pet() // Pet | Pet object that needs to be added to the store
35+
def pet = new Pet() // Pet | Pet object that needs to be added to the store
3636
37-
apiInstance.addPet(body)
37+
apiInstance.addPet(pet)
3838
{
3939
// on success
40-
println it
40+
def result = (Pet)it
41+
println result
42+
4143
}
4244
{
4345
// on failure

samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/PetApi.groovy

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PetApi {
99
String versionPath = ""
1010
ApiUtils apiUtils = new ApiUtils();
1111

12-
def addPet ( Pet body, Closure onSuccess, Closure onFailure) {
12+
def addPet ( Pet pet, Closure onSuccess, Closure onFailure) {
1313
String resourcePath = "/pet"
1414

1515
// params
@@ -19,19 +19,19 @@ class PetApi {
1919
def contentType
2020

2121
// verify required params are set
22-
if (body == null) {
23-
throw new RuntimeException("missing required params body")
22+
if (pet == null) {
23+
throw new RuntimeException("missing required params pet")
2424
}
2525

2626

2727

2828
contentType = 'application/json';
29-
bodyParams = body
29+
bodyParams = pet
3030

3131

3232
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
3333
"POST", "",
34-
null )
34+
Pet.class )
3535

3636
}
3737

@@ -140,7 +140,7 @@ class PetApi {
140140

141141
}
142142

143-
def updatePet ( Pet body, Closure onSuccess, Closure onFailure) {
143+
def updatePet ( Pet pet, Closure onSuccess, Closure onFailure) {
144144
String resourcePath = "/pet"
145145

146146
// params
@@ -150,19 +150,19 @@ class PetApi {
150150
def contentType
151151

152152
// verify required params are set
153-
if (body == null) {
154-
throw new RuntimeException("missing required params body")
153+
if (pet == null) {
154+
throw new RuntimeException("missing required params pet")
155155
}
156156

157157

158158

159159
contentType = 'application/json';
160-
bodyParams = body
160+
bodyParams = pet
161161

162162

163163
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
164164
"PUT", "",
165-
null )
165+
Pet.class )
166166

167167
}
168168

samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/StoreApi.groovy

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class StoreApi {
7676

7777
}
7878

79-
def placeOrder ( Order body, Closure onSuccess, Closure onFailure) {
79+
def placeOrder ( Order order, Closure onSuccess, Closure onFailure) {
8080
String resourcePath = "/store/order"
8181

8282
// params
@@ -86,14 +86,14 @@ class StoreApi {
8686
def contentType
8787

8888
// verify required params are set
89-
if (body == null) {
90-
throw new RuntimeException("missing required params body")
89+
if (order == null) {
90+
throw new RuntimeException("missing required params order")
9191
}
9292

9393

9494

9595
contentType = 'application/json';
96-
bodyParams = body
96+
bodyParams = order
9797

9898

9999
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,

samples/client/petstore/groovy/src/main/groovy/org/openapitools/api/UserApi.groovy

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UserApi {
99
String versionPath = ""
1010
ApiUtils apiUtils = new ApiUtils();
1111

12-
def createUser ( User body, Closure onSuccess, Closure onFailure) {
12+
def createUser ( User user, Closure onSuccess, Closure onFailure) {
1313
String resourcePath = "/user"
1414

1515
// params
@@ -19,14 +19,14 @@ class UserApi {
1919
def contentType
2020

2121
// verify required params are set
22-
if (body == null) {
23-
throw new RuntimeException("missing required params body")
22+
if (user == null) {
23+
throw new RuntimeException("missing required params user")
2424
}
2525

2626

2727

2828
contentType = 'application/json';
29-
bodyParams = body
29+
bodyParams = user
3030

3131

3232
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
@@ -35,7 +35,7 @@ class UserApi {
3535

3636
}
3737

38-
def createUsersWithArrayInput ( List<User> body, Closure onSuccess, Closure onFailure) {
38+
def createUsersWithArrayInput ( List<User> user, Closure onSuccess, Closure onFailure) {
3939
String resourcePath = "/user/createWithArray"
4040

4141
// params
@@ -45,14 +45,14 @@ class UserApi {
4545
def contentType
4646

4747
// verify required params are set
48-
if (body == null) {
49-
throw new RuntimeException("missing required params body")
48+
if (user == null) {
49+
throw new RuntimeException("missing required params user")
5050
}
5151

5252

5353

5454
contentType = 'application/json';
55-
bodyParams = body
55+
bodyParams = user
5656

5757

5858
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
@@ -61,7 +61,7 @@ class UserApi {
6161

6262
}
6363

64-
def createUsersWithListInput ( List<User> body, Closure onSuccess, Closure onFailure) {
64+
def createUsersWithListInput ( List<User> user, Closure onSuccess, Closure onFailure) {
6565
String resourcePath = "/user/createWithList"
6666

6767
// params
@@ -71,14 +71,14 @@ class UserApi {
7171
def contentType
7272

7373
// verify required params are set
74-
if (body == null) {
75-
throw new RuntimeException("missing required params body")
74+
if (user == null) {
75+
throw new RuntimeException("missing required params user")
7676
}
7777

7878

7979

8080
contentType = 'application/json';
81-
bodyParams = body
81+
bodyParams = user
8282

8383

8484
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
@@ -189,7 +189,7 @@ class UserApi {
189189

190190
}
191191

192-
def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) {
192+
def updateUser ( String username, User user, Closure onSuccess, Closure onFailure) {
193193
String resourcePath = "/user/${username}"
194194

195195
// params
@@ -203,14 +203,14 @@ class UserApi {
203203
throw new RuntimeException("missing required params username")
204204
}
205205
// verify required params are set
206-
if (body == null) {
207-
throw new RuntimeException("missing required params body")
206+
if (user == null) {
207+
throw new RuntimeException("missing required params user")
208208
}
209209

210210

211211

212212
contentType = 'application/json';
213-
bodyParams = body
213+
bodyParams = user
214214

215215

216216
apiUtils.invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, bodyParams, contentType,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.openapitools.model;
2+
3+
import groovy.transform.Canonical
4+
import io.swagger.annotations.ApiModel;
5+
import io.swagger.annotations.ApiModelProperty;
6+
7+
@Canonical
8+
class InlineObject {
9+
/* Updated name of the pet */
10+
String name
11+
/* Updated status of the pet */
12+
String status
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.openapitools.model;
2+
3+
import groovy.transform.Canonical
4+
import io.swagger.annotations.ApiModel;
5+
import io.swagger.annotations.ApiModelProperty;
6+
7+
@Canonical
8+
class InlineObject1 {
9+
/* Additional data to pass to server */
10+
String additionalMetadata
11+
/* file to upload */
12+
File file
13+
}

0 commit comments

Comments
 (0)