From a2d1edc6f5d4115a9eed29e71a63251c1ef0bfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=C5=ADlo=20Ebermann?= Date: Mon, 13 Mar 2017 14:46:28 +0100 Subject: [PATCH] Fix (partially) #4898 for groovy (#5030) * Fix (partially) #4898 for groovy. This also adds some TODOs for the missing path, form and body parameters. * Update Groovy samples (after partial fix for #4898) --- .../src/main/resources/Groovy/api.mustache | 8 +++-- .../main/groovy/io/swagger/api/PetApi.groovy | 34 ++++++++++++++----- .../groovy/io/swagger/api/StoreApi.groovy | 16 ++++++--- .../main/groovy/io/swagger/api/UserApi.groovy | 32 ++++++++++++----- 4 files changed, 66 insertions(+), 24 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache index c952718b6ec..9f82181d45e 100644 --- a/modules/swagger-codegen/src/main/resources/Groovy/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Groovy/api.mustache @@ -18,7 +18,7 @@ class {{classname}} { {{#operation}} def {{operationId}} ({{#allParams}} {{{dataType}}} {{paramName}},{{/allParams}} Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "{{path}}" // query params @@ -35,13 +35,15 @@ class {{classname}} { {{/allParams}} {{#queryParams}}if (!"null".equals(String.valueOf({{paramName}}))) - queryParams.put("{{paramName}}", String.valueOf({{paramName}})) + queryParams.put("{{baseName}}", String.valueOf({{paramName}})) {{/queryParams}} {{#headerParams}} - headerParams.put("{{paramName}}", {{paramName}}) + headerParams.put("{{baseName}}", {{paramName}}) {{/headerParams}} + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "{{httpMethod}}", "{{returnContainer}}", {{#returnBaseType}}{{{returnBaseType}}}.class {{/returnBaseType}}{{^returnBaseType}}null {{/returnBaseType}}) diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy index b1b43f81559..a223f4bbadb 100644 --- a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/PetApi.groovy @@ -17,7 +17,7 @@ class PetApi { String versionPath = "/api/v1" def addPet ( Pet body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet" // query params @@ -31,13 +31,15 @@ class PetApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", null ) } def deletePet ( Long petId, String apiKey, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/{petId}" // query params @@ -50,7 +52,9 @@ class PetApi { } - headerParams.put("apiKey", apiKey) + headerParams.put("api_key", apiKey) + + // Also still TODO: form params, body param invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "DELETE", "", @@ -58,7 +62,7 @@ class PetApi { } def findPetsByStatus ( List status, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/findByStatus" // query params @@ -74,13 +78,15 @@ class PetApi { queryParams.put("status", String.valueOf(status)) + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "array", Pet.class ) } def findPetsByTags ( List tags, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/findByTags" // query params @@ -96,13 +102,15 @@ class PetApi { queryParams.put("tags", String.valueOf(tags)) + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "array", Pet.class ) } def getPetById ( Long petId, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/{petId}" // query params @@ -116,13 +124,15 @@ class PetApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "", Pet.class ) } def updatePet ( Pet body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet" // query params @@ -136,13 +146,15 @@ class PetApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "PUT", "", null ) } def updatePetWithForm ( Long petId, String name, String status, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/{petId}" // query params @@ -156,13 +168,15 @@ class PetApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", null ) } def uploadFile ( Long petId, String additionalMetadata, File file, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/pet/{petId}/uploadImage" // query params @@ -176,6 +190,8 @@ class PetApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", ModelApiResponse.class ) diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy index 51047b4834b..bf74dd21266 100644 --- a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/StoreApi.groovy @@ -16,7 +16,7 @@ class StoreApi { String versionPath = "/api/v1" def deleteOrder ( String orderId, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/store/order/{orderId}" // query params @@ -30,13 +30,15 @@ class StoreApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "DELETE", "", null ) } def getInventory ( Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/store/inventory" // query params @@ -46,13 +48,15 @@ class StoreApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "map", Map.class ) } def getOrderById ( Long orderId, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/store/order/{orderId}" // query params @@ -66,13 +70,15 @@ class StoreApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "", Order.class ) } def placeOrder ( Order body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/store/order" // query params @@ -86,6 +92,8 @@ class StoreApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", Order.class ) diff --git a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy index 5a8a4b2eea8..411fc55ae86 100644 --- a/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy +++ b/samples/client/petstore/groovy/src/main/groovy/io/swagger/api/UserApi.groovy @@ -15,7 +15,7 @@ class UserApi { String versionPath = "/api/v1" def createUser ( User body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user" // query params @@ -29,13 +29,15 @@ class UserApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", null ) } def createUsersWithArrayInput ( List body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/createWithArray" // query params @@ -49,13 +51,15 @@ class UserApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", null ) } def createUsersWithListInput ( List body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/createWithList" // query params @@ -69,13 +73,15 @@ class UserApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "POST", "", null ) } def deleteUser ( String username, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/{username}" // query params @@ -89,13 +95,15 @@ class UserApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "DELETE", "", null ) } def getUserByName ( String username, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/{username}" // query params @@ -109,13 +117,15 @@ class UserApi { + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "", User.class ) } def loginUser ( String username, String password, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/login" // query params @@ -137,13 +147,15 @@ if (!"null".equals(String.valueOf(password))) queryParams.put("password", String.valueOf(password)) + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "", String.class ) } def logoutUser ( Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/logout" // query params @@ -153,13 +165,15 @@ if (!"null".equals(String.valueOf(password))) + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "GET", "", null ) } def updateUser ( String username, User body, Closure onSuccess, Closure onFailure) { - // create path and map variables + // create path and map path parameters (TODO) String resourcePath = "/user/{username}" // query params @@ -177,6 +191,8 @@ if (!"null".equals(String.valueOf(password))) + // Also still TODO: form params, body param + invokeApi(onSuccess, onFailure, basePath, versionPath, resourcePath, queryParams, headerParams, "PUT", "", null )