diff --git a/samples/client/petstore/python/PythonPetstoreCodegen.scala b/samples/client/petstore/python/PythonPetstoreCodegen.scala deleted file mode 100644 index 9758c384453d..000000000000 --- a/samples/client/petstore/python/PythonPetstoreCodegen.scala +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2014 Wordnik, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.wordnik.swagger.codegen.BasicPythonGenerator - -import java.io.File - -object PythonPetstoreCodegen extends BasicPythonGenerator { - def main(args: Array[String]) = generateClient(args) - - override def destinationDir = "samples/client/petstore/python" - - override def supportingFiles = List( - ("__init__.mustache", destinationDir, "__init__.py"), - ("swagger.mustache", destinationDir + File.separator + apiPackage.getOrElse(""), "swagger.py"), - ("__init__.mustache", destinationDir + File.separator + modelPackage.getOrElse(""), "__init__.py")) -} diff --git a/samples/client/petstore/python/PetApi.py b/samples/client/petstore/python/client/PetApi.py similarity index 63% rename from samples/client/petstore/python/PetApi.py rename to samples/client/petstore/python/client/PetApi.py index ef38b8eacd04..cd1a872752af 100644 --- a/samples/client/petstore/python/PetApi.py +++ b/samples/client/petstore/python/client/PetApi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -WordAPI.py -Copyright 2014 Wordnik, Inc. +PetApi.py +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -29,265 +29,16 @@ class PetApi(object): self.apiClient = apiClient - - def getPetById(self, petId, **kwargs): - """Find pet by ID - - Args: - petId, long: ID of pet that needs to be fetched (required) - - - - Returns: Pet - """ - - allParams = ['petId'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method getPetById" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet/{petId}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'GET' - - queryParams = {} - headerParams = {} - - if ('petId' in params): - replacement = str(self.apiClient.toPathValue(params['petId'])) - resourcePath = resourcePath.replace('{' + 'petId' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - if not response: - return None - - responseObject = self.apiClient.deserialize(response, 'Pet') - return responseObject - - - - - def deletePet(self, petId, **kwargs): - """Deletes a pet - - Args: - petId, str: Pet id to delete (required) - - - - Returns: - """ - - allParams = ['petId'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method deletePet" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet/{petId}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'DELETE' - - queryParams = {} - headerParams = {} - - if ('petId' in params): - replacement = str(self.apiClient.toPathValue(params['petId'])) - resourcePath = resourcePath.replace('{' + 'petId' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def partialUpdate(self, petId, body, **kwargs): - """partial updates to a pet - - Args: - petId, str: ID of pet that needs to be fetched (required) - - body, Pet: Pet object that needs to be added to the store (required) - - - - Returns: Array[Pet] - """ - - allParams = ['petId', 'body'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method partialUpdate" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet/{petId}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'PATCH' - - queryParams = {} - headerParams = {} - - if ('petId' in params): - replacement = str(self.apiClient.toPathValue(params['petId'])) - resourcePath = resourcePath.replace('{' + 'petId' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - if not response: - return None - - responseObject = self.apiClient.deserialize(response, 'Array[Pet]') - return responseObject - - - - - def updatePetWithForm(self, petId, **kwargs): - """Updates a pet in the store with form data - - Args: - petId, str: ID of pet that needs to be updated (required) - - name, str: Updated name of the pet (optional) - - status, str: Updated status of the pet (optional) - - - - Returns: - """ - - allParams = ['petId', 'name', 'status'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method updatePetWithForm" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet/{petId}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'POST' - - queryParams = {} - headerParams = {} - - if ('petId' in params): - replacement = str(self.apiClient.toPathValue(params['petId'])) - resourcePath = resourcePath.replace('{' + 'petId' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def uploadFile(self, **kwargs): - """uploads an image - - Args: - additionalMetadata, str: Additional data to pass to server (optional) - - body, File: file to upload (optional) - - - - Returns: - """ - - allParams = ['additionalMetadata', 'body'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method uploadFile" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet/uploadImage' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'POST' - - queryParams = {} - headerParams = {} - - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def addPet(self, body, **kwargs): - """Add a new pet to the store - - Args: - body, Pet: Pet object that needs to be added to the store (required) - - - - Returns: - """ - - allParams = ['body'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method addPet" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/pet' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'POST' - - queryParams = {} - headerParams = {} - - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def updatePet(self, body, **kwargs): + + def updatePet(self, **kwargs): """Update an existing pet Args: - body, Pet: Pet object that needs to be updated in the store (required) - - + body, Pet: Pet object that needs to be added to the store (required) + + + Returns: """ @@ -306,25 +57,101 @@ class PetApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None - postData = (params['body'] if 'body' in params else None) + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = 'application/json,application/xml'; + + + + + + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) + + + + + + def addPet(self, **kwargs): + """Add a new pet to the store + + Args: + + body, Pet: Pet object that needs to be added to the store (required) + + + + Returns: + """ + + allParams = ['body'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method addPet" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/pet' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'POST' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = 'application/json,application/xml'; - def findPetsByStatus(self, status= None, **kwargs): + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + + + def findPetsByStatus(self, **kwargs): """Finds Pets by status Args: - status, str: Status values that need to be considered for filter (required) - - - Returns: Array[Pet] + status, list[str]: Status values that need to be considered for filter (required) + + + + Returns: list[Pet] """ allParams = ['status'] @@ -342,32 +169,51 @@ class PetApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + if ('status' in params): queryParams['status'] = self.apiClient.toPathValue(params['status']) - postData = (params['body'] if 'body' in params else None) + + + + + + + + + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) + if not response: return None - responseObject = self.apiClient.deserialize(response, 'Array[Pet]') + responseObject = self.apiClient.deserialize(response, 'list[Pet]') return responseObject - - - def findPetsByTags(self, tags, **kwargs): + + + def findPetsByTags(self, **kwargs): """Finds Pets by tags Args: - tags, str: Tags to filter by (required) - - - Returns: Array[Pet] + tags, list[str]: Tags to filter by (required) + + + + Returns: list[Pet] """ allParams = ['tags'] @@ -385,25 +231,300 @@ class PetApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + if ('tags' in params): queryParams['tags'] = self.apiClient.toPathValue(params['tags']) - postData = (params['body'] if 'body' in params else None) + + + + + + + + + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) + if not response: return None - responseObject = self.apiClient.deserialize(response, 'Array[Pet]') + responseObject = self.apiClient.deserialize(response, 'list[Pet]') return responseObject + + + + def getPetById(self, **kwargs): + """Find pet by ID + + Args: + + petId, long: ID of pet that needs to be fetched (required) + + + + Returns: Pet + """ + + allParams = ['petId'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method getPetById" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/pet/{petId}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'GET' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + if ('petId' in params): + replacement = str(self.apiClient.toPathValue(params['petId'])) + resourcePath = resourcePath.replace('{' + 'petId' + '}', + replacement) + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + if not response: + return None + + responseObject = self.apiClient.deserialize(response, 'Pet') + return responseObject + + + + + def updatePetWithForm(self, **kwargs): + """Updates a pet in the store with form data + + Args: + + petId, str: ID of pet that needs to be updated (required) + + + name, str: Updated name of the pet (required) + + + status, str: Updated status of the pet (required) + + + + Returns: + """ + + allParams = ['petId', 'name', 'status'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method updatePetWithForm" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/pet/{petId}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'POST' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + + + + + + + if ('petId' in params): + replacement = str(self.apiClient.toPathValue(params['petId'])) + resourcePath = resourcePath.replace('{' + 'petId' + '}', + replacement) + + + + if ('name' in params): + formParams['name'] = params['name'] + + if ('status' in params): + formParams['status'] = params['status'] + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + + + def deletePet(self, **kwargs): + """Deletes a pet + + Args: + + api_key, str: (required) + + + petId, long: Pet id to delete (required) + + + + Returns: + """ + + allParams = ['api_key', 'petId'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method deletePet" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/pet/{petId}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'DELETE' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + if ('api_key' in params): + headerParams['api_key'] = params['api_key'] + + + + if ('petId' in params): + replacement = str(self.apiClient.toPathValue(params['petId'])) + resourcePath = resourcePath.replace('{' + 'petId' + '}', + replacement) + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + + + def uploadFile(self, **kwargs): + """uploads an image + + Args: + + additionalMetadata, str: Additional data to pass to server (required) + + + file, file: file to upload (required) + + + + Returns: + """ + + allParams = ['additionalMetadata', 'file'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method uploadFile" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/pet/{petId}/uploadImage' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'POST' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = 'multipart/form-data'; + + + + + + + + + if ('additionalMetadata' in params): + formParams['additionalMetadata'] = params['additionalMetadata'] + + if ('file' in params): + files['file'] = params['file'] + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + - - diff --git a/samples/client/petstore/python/StoreApi.py b/samples/client/petstore/python/client/StoreApi.py similarity index 58% rename from samples/client/petstore/python/StoreApi.py rename to samples/client/petstore/python/client/StoreApi.py index 547aed42ba90..f47a4408cbb0 100644 --- a/samples/client/petstore/python/StoreApi.py +++ b/samples/client/petstore/python/client/StoreApi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -WordAPI.py -Copyright 2014 Wordnik, Inc. +StoreApi.py +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -29,15 +29,134 @@ class StoreApi(object): self.apiClient = apiClient + + def getInventory(self, **kwargs): + """Returns pet inventories by status - def getOrderById(self, orderId, **kwargs): + Args: + + + Returns: map(String, int) + """ + + allParams = [] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method getInventory" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/store/inventory' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'GET' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + if not response: + return None + + responseObject = self.apiClient.deserialize(response, 'map(String, int)') + return responseObject + + + + + def placeOrder(self, **kwargs): + """Place an order for a pet + + Args: + + body, Order: order placed for purchasing the pet (required) + + + + Returns: Order + """ + + allParams = ['body'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method placeOrder" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/store/order' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'POST' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + if not response: + return None + + responseObject = self.apiClient.deserialize(response, 'Order') + return responseObject + + + + + def getOrderById(self, **kwargs): """Find purchase order by ID Args: - orderId, str: ID of pet that needs to be fetched (required) - - + orderId, str: ID of pet that needs to be fetched (required) + + + Returns: Order """ @@ -56,33 +175,52 @@ class StoreApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + if ('orderId' in params): replacement = str(self.apiClient.toPathValue(params['orderId'])) resourcePath = resourcePath.replace('{' + 'orderId' + '}', replacement) - postData = (params['body'] if 'body' in params else None) + + + + + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) + if not response: return None responseObject = self.apiClient.deserialize(response, 'Order') return responseObject - - - def deleteOrder(self, orderId, **kwargs): + + + def deleteOrder(self, **kwargs): """Delete purchase order by ID Args: - orderId, str: ID of the order that needs to be deleted (required) - - + orderId, str: ID of the order that needs to be deleted (required) + + + Returns: """ @@ -101,58 +239,36 @@ class StoreApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + if ('orderId' in params): replacement = str(self.apiClient.toPathValue(params['orderId'])) resourcePath = resourcePath.replace('{' + 'orderId' + '}', replacement) - postData = (params['body'] if 'body' in params else None) + + + + + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) - - - def placeOrder(self, body, **kwargs): - """Place an order for a pet - - Args: - body, Order: order placed for purchasing the pet (required) - - - - Returns: - """ - - allParams = ['body'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method placeOrder" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/store/order' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'POST' - - queryParams = {} - headerParams = {} - - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - diff --git a/samples/client/petstore/python/UserApi.py b/samples/client/petstore/python/client/UserApi.py similarity index 70% rename from samples/client/petstore/python/UserApi.py rename to samples/client/petstore/python/client/UserApi.py index 522ec36295e1..a357b785c574 100644 --- a/samples/client/petstore/python/UserApi.py +++ b/samples/client/petstore/python/client/UserApi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ -WordAPI.py -Copyright 2014 Wordnik, Inc. +UserApi.py +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -29,223 +29,16 @@ class UserApi(object): self.apiClient = apiClient - - def updateUser(self, username, body, **kwargs): - """Updated user - - Args: - username, str: name that need to be deleted (required) - - body, User: Updated user object (required) - - - - Returns: - """ - - allParams = ['username', 'body'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method updateUser" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/user/{username}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'PUT' - - queryParams = {} - headerParams = {} - - if ('username' in params): - replacement = str(self.apiClient.toPathValue(params['username'])) - resourcePath = resourcePath.replace('{' + 'username' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def deleteUser(self, username, **kwargs): - """Delete user - - Args: - username, str: The name that needs to be deleted (required) - - - - Returns: - """ - - allParams = ['username'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method deleteUser" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/user/{username}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'DELETE' - - queryParams = {} - headerParams = {} - - if ('username' in params): - replacement = str(self.apiClient.toPathValue(params['username'])) - resourcePath = resourcePath.replace('{' + 'username' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def getUserByName(self, username, **kwargs): - """Get user by user name - - Args: - username, str: The name that needs to be fetched. Use user1 for testing. (required) - - - - Returns: User - """ - - allParams = ['username'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method getUserByName" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/user/{username}' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'GET' - - queryParams = {} - headerParams = {} - - if ('username' in params): - replacement = str(self.apiClient.toPathValue(params['username'])) - resourcePath = resourcePath.replace('{' + 'username' + '}', - replacement) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - if not response: - return None - - responseObject = self.apiClient.deserialize(response, 'User') - return responseObject - - - - - def loginUser(self, username, password, **kwargs): - """Logs user into the system - - Args: - username, str: The user name for login (required) - - password, str: The password for login in clear text (required) - - - - Returns: str - """ - - allParams = ['username', 'password'] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method loginUser" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/user/login' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'GET' - - queryParams = {} - headerParams = {} - - if ('username' in params): - queryParams['username'] = self.apiClient.toPathValue(params['username']) - if ('password' in params): - queryParams['password'] = self.apiClient.toPathValue(params['password']) - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - if not response: - return None - - responseObject = self.apiClient.deserialize(response, 'str') - return responseObject - - - - - def logoutUser(self, **kwargs): - """Logs out current logged in user session - - Args: - - - Returns: - """ - - allParams = [] - - params = locals() - for (key, val) in params['kwargs'].iteritems(): - if key not in allParams: - raise TypeError("Got an unexpected keyword argument '%s' to method logoutUser" % key) - params[key] = val - del params['kwargs'] - - resourcePath = '/user/logout' - resourcePath = resourcePath.replace('{format}', 'json') - method = 'GET' - - queryParams = {} - headerParams = {} - - postData = (params['body'] if 'body' in params else None) - - response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) - - - - - - def createUser(self, body, **kwargs): + + def createUser(self, **kwargs): """Create user Args: - body, User: Created user object (required) - - + body, User: Created user object (required) + + + Returns: """ @@ -264,24 +57,44 @@ class UserApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None - postData = (params['body'] if 'body' in params else None) + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) - - - def createUsersWithArrayInput(self, body, **kwargs): + + + def createUsersWithArrayInput(self, **kwargs): """Creates list of users with given input array Args: - body, list[User]: List of user object (required) - - + body, list[User]: List of user object (required) + + + Returns: """ @@ -300,24 +113,44 @@ class UserApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None - postData = (params['body'] if 'body' in params else None) + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) - - - def createUsersWithListInput(self, body, **kwargs): - """Creates list of users with given list input + + + def createUsersWithListInput(self, **kwargs): + """Creates list of users with given input array Args: - body, list[User]: List of user object (required) - - + body, list[User]: List of user object (required) + + + Returns: """ @@ -336,18 +169,338 @@ class UserApi(object): queryParams = {} headerParams = {} + formParams = {} + files = {} + bodyParam = None - postData = (params['body'] if 'body' in params else None) + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) response = self.apiClient.callAPI(resourcePath, method, queryParams, - postData, headerParams) + postData, headerParams, files=files) + + + + + + def loginUser(self, **kwargs): + """Logs user into the system + + Args: + + username, str: The user name for login (required) + + + password, str: The password for login in clear text (required) + + + + Returns: str + """ + + allParams = ['username', 'password'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method loginUser" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/user/login' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'GET' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + if ('username' in params): + queryParams['username'] = self.apiClient.toPathValue(params['username']) + + if ('password' in params): + queryParams['password'] = self.apiClient.toPathValue(params['password']) + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + if not response: + return None + + responseObject = self.apiClient.deserialize(response, 'str') + return responseObject + + + + + def logoutUser(self, **kwargs): + """Logs out current logged in user session + + Args: + + + Returns: + """ + + allParams = [] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method logoutUser" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/user/logout' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'GET' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + + + def getUserByName(self, **kwargs): + """Get user by user name + + Args: + + username, str: The name that needs to be fetched. Use user1 for testing. (required) + + + + Returns: User + """ + + allParams = ['username'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method getUserByName" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/user/{username}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'GET' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + if ('username' in params): + replacement = str(self.apiClient.toPathValue(params['username'])) + resourcePath = resourcePath.replace('{' + 'username' + '}', + replacement) + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + if not response: + return None + + responseObject = self.apiClient.deserialize(response, 'User') + return responseObject + + + + + def updateUser(self, **kwargs): + """Updated user + + Args: + + username, str: name that need to be deleted (required) + + + body, User: Updated user object (required) + + + + Returns: + """ + + allParams = ['username', 'body'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method updateUser" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/user/{username}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'PUT' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + if ('username' in params): + replacement = str(self.apiClient.toPathValue(params['username'])) + resourcePath = resourcePath.replace('{' + 'username' + '}', + replacement) + + + + + + if ('body' in params): + bodyParam = params['body'] + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + + + def deleteUser(self, **kwargs): + """Delete user + + Args: + + username, str: The name that needs to be deleted (required) + + + + Returns: + """ + + allParams = ['username'] + + params = locals() + for (key, val) in params['kwargs'].iteritems(): + if key not in allParams: + raise TypeError("Got an unexpected keyword argument '%s' to method deleteUser" % key) + params[key] = val + del params['kwargs'] + + resourcePath = '/user/{username}' + resourcePath = resourcePath.replace('{format}', 'json') + method = 'DELETE' + + queryParams = {} + headerParams = {} + formParams = {} + files = {} + bodyParam = None + + headerParams['Accept'] = 'application/json,application/xml'; + headerParams['Content-Type'] = ''; + + + + + + + if ('username' in params): + replacement = str(self.apiClient.toPathValue(params['username'])) + resourcePath = resourcePath.replace('{' + 'username' + '}', + replacement) + + + + + + + postData = (formParams if formParams else bodyParam) + + response = self.apiClient.callAPI(resourcePath, method, queryParams, + postData, headerParams, files=files) + + + + - - diff --git a/samples/client/petstore/python/__init__.py b/samples/client/petstore/python/client/__init__.py similarity index 99% rename from samples/client/petstore/python/__init__.py rename to samples/client/petstore/python/client/__init__.py index 39f84514fe91..4b41ee706c70 100644 --- a/samples/client/petstore/python/__init__.py +++ b/samples/client/petstore/python/client/__init__.py @@ -7,4 +7,3 @@ __all__ = [] for module in os.listdir(os.path.dirname(__file__)): if module != '__init__.py' and module[-3:] == '.py': __all__.append(module[:-3]) - diff --git a/samples/client/petstore/python/models/Category.py b/samples/client/petstore/python/client/models/Category.py similarity index 87% rename from samples/client/petstore/python/models/Category.py rename to samples/client/petstore/python/client/models/Category.py index 73238af39d22..245397c3f1b6 100644 --- a/samples/client/petstore/python/models/Category.py +++ b/samples/client/petstore/python/client/models/Category.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2014 Wordnik, Inc. +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ Copyright 2014 Wordnik, Inc. See the License for the specific language governing permissions and limitations under the License. """ + class Category: """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" @@ -21,12 +22,19 @@ class Category: def __init__(self): self.swaggerTypes = { + 'id': 'long', + + 'name': 'str' - + } + + self.id = None # long + + self.name = None # str diff --git a/samples/client/petstore/python/models/Order.py b/samples/client/petstore/python/client/models/Order.py similarity index 65% rename from samples/client/petstore/python/models/Order.py rename to samples/client/petstore/python/client/models/Order.py index 24e43faad5fb..e6d72fea84cf 100644 --- a/samples/client/petstore/python/models/Order.py +++ b/samples/client/petstore/python/client/models/Order.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2014 Wordnik, Inc. +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ Copyright 2014 Wordnik, Inc. See the License for the specific language governing permissions and limitations under the License. """ + class Order: """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" @@ -21,19 +22,44 @@ class Order: def __init__(self): self.swaggerTypes = { + 'id': 'long', + + 'petId': 'long', + + 'quantity': 'int', - 'status': 'str', - 'shipDate': 'datetime' - + + + 'shipDate': 'DateTime', + + + 'status': 'StatusEnum', + + + 'complete': 'bool' + } - self.id = None # long - self.petId = None # long - self.quantity = None # int - #Order Status - self.status = None # str - self.shipDate = None # datetime + + + self.id = None # long + + + self.petId = None # long + + + self.quantity = None # int + + + self.shipDate = None # DateTime + + #Order Status + + self.status = None # StatusEnum + + + self.complete = None # bool diff --git a/samples/client/petstore/python/models/Pet.py b/samples/client/petstore/python/client/models/Pet.py similarity index 75% rename from samples/client/petstore/python/models/Pet.py rename to samples/client/petstore/python/client/models/Pet.py index 441285951e6b..e0473f098794 100644 --- a/samples/client/petstore/python/models/Pet.py +++ b/samples/client/petstore/python/client/models/Pet.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2014 Wordnik, Inc. +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ Copyright 2014 Wordnik, Inc. See the License for the specific language governing permissions and limitations under the License. """ + class Pet: """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" @@ -21,22 +22,44 @@ class Pet: def __init__(self): self.swaggerTypes = { + 'id': 'long', + + 'category': 'Category', + + 'name': 'str', + + 'photoUrls': 'list[str]', + + 'tags': 'list[Tag]', - 'status': 'str' - + + + 'status': 'StatusEnum' + } - #unique identifier for the pet - self.id = None # long - self.category = None # Category - self.name = None # str - self.photoUrls = None # list[str] - self.tags = None # list[Tag] - #pet status in the store - self.status = None # str + + + self.id = None # long + + + self.category = None # Category + + + self.name = None # str + + + self.photoUrls = None # list[str] + + + self.tags = None # list[Tag] + + #pet status in the store + + self.status = None # StatusEnum diff --git a/samples/client/petstore/python/models/Tag.py b/samples/client/petstore/python/client/models/Tag.py similarity index 87% rename from samples/client/petstore/python/models/Tag.py rename to samples/client/petstore/python/client/models/Tag.py index 39a54101adb2..bd565e2bab3b 100644 --- a/samples/client/petstore/python/models/Tag.py +++ b/samples/client/petstore/python/client/models/Tag.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2014 Wordnik, Inc. +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ Copyright 2014 Wordnik, Inc. See the License for the specific language governing permissions and limitations under the License. """ + class Tag: """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" @@ -21,12 +22,19 @@ class Tag: def __init__(self): self.swaggerTypes = { + 'id': 'long', + + 'name': 'str' - + } + + self.id = None # long + + self.name = None # str diff --git a/samples/client/petstore/python/models/User.py b/samples/client/petstore/python/client/models/User.py similarity index 77% rename from samples/client/petstore/python/models/User.py rename to samples/client/petstore/python/client/models/User.py index 7779cd618eb0..81466c88530f 100644 --- a/samples/client/petstore/python/models/User.py +++ b/samples/client/petstore/python/client/models/User.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2014 Wordnik, Inc. +Copyright 2015 Reverb Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ Copyright 2014 Wordnik, Inc. See the License for the specific language governing permissions and limitations under the License. """ + class User: """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" @@ -21,25 +22,56 @@ class User: def __init__(self): self.swaggerTypes = { + 'id': 'long', - 'firstName': 'str', + + 'username': 'str', + + + 'firstName': 'str', + + 'lastName': 'str', + + 'email': 'str', + + 'password': 'str', + + 'phone': 'str', + + 'userStatus': 'int' - + } + + self.id = None # long - self.firstName = None # str + + self.username = None # str + + + self.firstName = None # str + + self.lastName = None # str + + self.email = None # str + + self.password = None # str + + self.phone = None # str + #User Status + self.userStatus = None # int diff --git a/samples/client/petstore/python/models/__init__.py b/samples/client/petstore/python/client/models/__init__.py similarity index 99% rename from samples/client/petstore/python/models/__init__.py rename to samples/client/petstore/python/client/models/__init__.py index 39f84514fe91..4b41ee706c70 100644 --- a/samples/client/petstore/python/models/__init__.py +++ b/samples/client/petstore/python/client/models/__init__.py @@ -7,4 +7,3 @@ __all__ = [] for module in os.listdir(os.path.dirname(__file__)): if module != '__init__.py' and module[-3:] == '.py': __all__.append(module[:-3]) - diff --git a/samples/client/petstore/python/swagger.py b/samples/client/petstore/python/client/swagger.py similarity index 79% rename from samples/client/petstore/python/swagger.py rename to samples/client/petstore/python/client/swagger.py index 1065ad800e78..59b6d38fbd60 100644 --- a/samples/client/petstore/python/swagger.py +++ b/samples/client/petstore/python/client/swagger.py @@ -12,6 +12,9 @@ import urllib2 import httplib import json import datetime +import mimetypes +import random +import string from models import * @@ -26,9 +29,10 @@ class ApiClient: self.apiKey = apiKey self.apiServer = apiServer self.cookie = None + self.boundary = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(30)) def callAPI(self, resourcePath, method, queryParams, postData, - headerParams=None): + headerParams=None, files=None): url = self.apiServer + resourcePath headers = {} @@ -36,7 +40,6 @@ class ApiClient: for param, value in headerParams.iteritems(): headers[param] = value - #headers['Content-type'] = 'application/json' headers['api_key'] = self.apiKey if self.cookie: @@ -60,9 +63,16 @@ class ApiClient: elif method in ['POST', 'PUT', 'DELETE']: if postData: - headers['Content-type'] = 'application/json' - data = self.sanitizeForSerialization(postData) - data = json.dumps(data) + postData = self.sanitizeForSerialization(postData) + if 'Content-type' not in headers: + headers['Content-type'] = 'application/json' + data = json.dumps(postData) + elif headers['Content-type'] == 'multipart/form-data': + data = self.buildMultipartFormData(postData, files) + headers['Content-type'] = 'multipart/form-data; boundary={0}'.format(self.boundary) + headers['Content-length'] = str(len(data)) + else: + data = urllib.urlencode(postData) else: raise Exception('Method ' + method + ' is not recognized.') @@ -124,6 +134,38 @@ class ApiClient: elif type(postData) not in safeToDump: data = json.dumps(postData.__dict__) + def buildMultipartFormData(self, postData, files): + def escape_quotes(s): + return s.replace('"', '\\"') + + lines = [] + + for name, value in postData.items(): + lines.extend(( + '--{0}'.format(self.boundary), + 'Content-Disposition: form-data; name="{0}"'.format(escape_quotes(name)), + '', + str(value), + )) + + for name, filepath in files.items(): + f = open(filepath, 'r') + filename = filepath.split('/')[-1] + mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' + lines.extend(( + '--{0}'.format(self.boundary), + 'Content-Disposition: form-data; name="{0}"; filename="{1}"'.format(escape_quotes(name), escape_quotes(filename)), + 'Content-Type: {0}'.format(mimetype), + '', + f.read() + )) + + lines.extend(( + '--{0}--'.format(self.boundary), + '' + )) + return '\r\n'.join(lines) + def deserialize(self, obj, objClass): """Derialize a JSON string into an object. @@ -206,4 +248,3 @@ class MethodRequest(urllib2.Request): def get_method(self): return getattr(self, 'method', urllib2.Request.get_method(self)) -