From a2240ac619df5d0bdedad884b1374dc06ab772e3 Mon Sep 17 00:00:00 2001 From: Takuro Wada Date: Fri, 26 May 2017 18:24:06 +0900 Subject: [PATCH] [htmlDocs2] inconsistent python method name between html2 and python generator (#5711) --- .../io/swagger/codegen/CodegenOperation.java | 1 + .../io/swagger/codegen/DefaultCodegen.java | 1 + .../htmlDocs2/sample_python.mustache | 2 +- samples/html2/.swagger-codegen/VERSION | 1 + samples/html2/index.html | 40 +++++++++---------- 5 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 samples/html2/.swagger-codegen/VERSION diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index c72a844e056..853a8ce778a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -37,6 +37,7 @@ public class CodegenOperation { public String nickname; // legacy support public String operationIdLowerCase; // for mardown documentation public String operationIdCamelCase; // for class names + public String operationIdSnakeCase; /** * Check if there's at least one parameter diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 4bf245894a9..249a049259e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2888,6 +2888,7 @@ public class DefaultCodegen { co.operationId = uniqueName; co.operationIdLowerCase = uniqueName.toLowerCase(); co.operationIdCamelCase = DefaultCodegen.camelize(uniqueName); + co.operationIdSnakeCase = DefaultCodegen.underscore(uniqueName); opList.add(co); co.baseName = tag; } diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs2/sample_python.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs2/sample_python.mustache index cb6c5509190..0afe46abce2 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs2/sample_python.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs2/sample_python.mustache @@ -22,7 +22,7 @@ api_instance = {{{pythonPackageName}}}.{{{classname}}}() try: {{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationIdSnakeCase}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} pprint(api_response){{/returnType}} except ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) \ No newline at end of file diff --git a/samples/html2/.swagger-codegen/VERSION b/samples/html2/.swagger-codegen/VERSION new file mode 100644 index 00000000000..7fea99011a6 --- /dev/null +++ b/samples/html2/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/html2/index.html b/samples/html2/index.html index 7808570cd31..4f854bc990f 100644 --- a/samples/html2/index.html +++ b/samples/html2/index.html @@ -1200,7 +1200,7 @@ body = # Pet | Pet object that needs to be added to the store try: # Add a new pet to the store - api_instance.addPet(body) + api_instance.add_pet(body) except ApiException as e: print("Exception when calling PetApi->addPet: %s\n" % e) @@ -1498,7 +1498,7 @@ apiKey = apiKey_example # String | (optional) try: # Deletes a pet - api_instance.deletePet(petId, apiKey=apiKey) + api_instance.delete_pet(petId, apiKey=apiKey) except ApiException as e: print("Exception when calling PetApi->deletePet: %s\n" % e) @@ -1831,7 +1831,7 @@ status = # array[String] | Status values that need to be considered for filter try: # Finds Pets by status - api_response = api_instance.findPetsByStatus(status) + api_response = api_instance.find_pets_by_status(status) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->findPetsByStatus: %s\n" % e) @@ -2177,7 +2177,7 @@ tags = # array[String] | Tags to filter by try: # Finds Pets by tags - api_response = api_instance.findPetsByTags(tags) + api_response = api_instance.find_pets_by_tags(tags) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->findPetsByTags: %s\n" % e) @@ -2535,7 +2535,7 @@ petId = 789 # Long | ID of pet to return try: # Find pet by ID - api_response = api_instance.getPetById(petId) + api_response = api_instance.get_pet_by_id(petId) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->getPetById: %s\n" % e) @@ -2873,7 +2873,7 @@ body = # Pet | Pet object that needs to be added to the store try: # Update an existing pet - api_instance.updatePet(body) + api_instance.update_pet(body) except ApiException as e: print("Exception when calling PetApi->updatePet: %s\n" % e) @@ -3196,7 +3196,7 @@ status = status_example # String | Updated status of the pet (optional) try: # Updates a pet in the store with form data - api_instance.updatePetWithForm(petId, name=name, status=status) + api_instance.update_pet_with_form(petId, name=name, status=status) except ApiException as e: print("Exception when calling PetApi->updatePetWithForm: %s\n" % e) @@ -3583,7 +3583,7 @@ file = /path/to/file.txt # File | file to upload (optional) try: # uploads an image - api_response = api_instance.uploadFile(petId, additionalMetadata=additionalMetadata, file=file) + api_response = api_instance.upload_file(petId, additionalMetadata=additionalMetadata, file=file) pprint(api_response) except ApiException as e: print("Exception when calling PetApi->uploadFile: %s\n" % e) @@ -3954,7 +3954,7 @@ orderId = orderId_example # String | ID of the order that needs to be deleted try: # Delete purchase order by ID - api_instance.deleteOrder(orderId) + api_instance.delete_order(orderId) except ApiException as e: print("Exception when calling StoreApi->deleteOrder: %s\n" % e) @@ -4259,7 +4259,7 @@ api_instance = swagger_client.StoreApi() try: # Returns pet inventories by status - api_response = api_instance.getInventory() + api_response = api_instance.get_inventory() pprint(api_response) except ApiException as e: print("Exception when calling StoreApi->getInventory: %s\n" % e) @@ -4525,7 +4525,7 @@ orderId = 789 # Long | ID of pet that needs to be fetched try: # Find purchase order by ID - api_response = api_instance.getOrderById(orderId) + api_response = api_instance.get_order_by_id(orderId) pprint(api_response) except ApiException as e: print("Exception when calling StoreApi->getOrderById: %s\n" % e) @@ -4846,7 +4846,7 @@ body = # Order | order placed for purchasing the pet try: # Place an order for a pet - api_response = api_instance.placeOrder(body) + api_response = api_instance.place_order(body) pprint(api_response) except ApiException as e: print("Exception when calling StoreApi->placeOrder: %s\n" % e) @@ -5153,7 +5153,7 @@ body = # User | Created user object try: # Create user - api_instance.createUser(body) + api_instance.create_user(body) except ApiException as e: print("Exception when calling UserApi->createUser: %s\n" % e) @@ -5413,7 +5413,7 @@ body = # array[User] | List of user object try: # Creates list of users with given input array - api_instance.createUsersWithArrayInput(body) + api_instance.create_users_with_array_input(body) except ApiException as e: print("Exception when calling UserApi->createUsersWithArrayInput: %s\n" % e) @@ -5676,7 +5676,7 @@ body = # array[User] | List of user object try: # Creates list of users with given input array - api_instance.createUsersWithListInput(body) + api_instance.create_users_with_list_input(body) except ApiException as e: print("Exception when calling UserApi->createUsersWithListInput: %s\n" % e) @@ -5939,7 +5939,7 @@ username = username_example # String | The name that needs to be deleted try: # Delete user - api_instance.deleteUser(username) + api_instance.delete_user(username) except ApiException as e: print("Exception when calling UserApi->deleteUser: %s\n" % e) @@ -6213,7 +6213,7 @@ username = username_example # String | The name that needs to be fetched. Use us try: # Get user by user name - api_response = api_instance.getUserByName(username) + api_response = api_instance.get_user_by_name(username) pprint(api_response) except ApiException as e: print("Exception when calling UserApi->getUserByName: %s\n" % e) @@ -6541,7 +6541,7 @@ password = password_example # String | The password for login in clear text try: # Logs user into the system - api_response = api_instance.loginUser(username, password) + api_response = api_instance.login_user(username, password) pprint(api_response) except ApiException as e: print("Exception when calling UserApi->loginUser: %s\n" % e) @@ -6903,7 +6903,7 @@ api_instance = swagger_client.UserApi() try: # Logs out current logged in user session - api_instance.logoutUser() + api_instance.logout_user() except ApiException as e: print("Exception when calling UserApi->logoutUser: %s\n" % e) @@ -7131,7 +7131,7 @@ body = # User | Updated user object try: # Updated user - api_instance.updateUser(username, body) + api_instance.update_user(username, body) except ApiException as e: print("Exception when calling UserApi->updateUser: %s\n" % e)