diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java index 87489eabdd7e..431795c4c946 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java @@ -17,6 +17,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig { static Logger LOGGER = LoggerFactory.getLogger(LuaClientCodegen.class); + protected String specFolder = "spec"; protected String packageName = "swagger-client"; protected String packageVersion = "1.0.0-1"; protected String apiDocPath = "docs/"; @@ -142,8 +143,8 @@ public void processOpts() { additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); - apiTestTemplateFiles.clear(); // TODO: add api test template - modelTestTemplateFiles.clear(); // TODO: add model test template + apiTestTemplateFiles.put("api_test.mustache", ".lua"); + modelTestTemplateFiles.put("model_test.mustache", ".lua"); apiDocTemplateFiles.clear(); // TODO: add api doc template modelDocTemplateFiles.clear(); // TODO: add model doc template @@ -260,6 +261,16 @@ public String toApiFilename(String name) { return underscore(name) + "_api"; } + @Override + public String toApiTestFilename(String name) { + return toApiFilename(name) + "_spec"; + } + + @Override + public String toModelTestFilename(String name) { + return toModelFilename(name) + "_spec"; + } + /** * Overrides postProcessParameter to add a vendor extension "x-exportParamName". * This is useful when paramName starts with a lowercase letter, but we need that @@ -270,21 +281,16 @@ public String toApiFilename(String name) { @Override public void postProcessParameter(CodegenParameter parameter){ - //// Give the base class a chance to process - //super.postProcessParameter(parameter); - - //char firstChar = parameter.paramName.charAt(0); - - //if (Character.isUpperCase(firstChar)) { - // // First char is already uppercase, just use paramName. - // parameter.vendorExtensions.put("x-exportParamName", parameter.paramName); + } - //} + @Override + public String apiTestFileFolder() { + return outputFolder + File.separator + apiPackage + File.separator + specFolder.replace("/", File.separator); + } - //// It's a lowercase first char, let's convert it to uppercase - //StringBuilder sb = new StringBuilder(parameter.paramName); - //sb.setCharAt(0, Character.toUpperCase(firstChar)); - //parameter.vendorExtensions.put("x-exportParamName", sb.toString()); + @Override + public String modelTestFileFolder() { + return outputFolder + File.separator + modelPackage + File.separator + specFolder.replace("/", File.separator); } @Override diff --git a/modules/swagger-codegen/src/main/resources/lua/api_test.mustache b/modules/swagger-codegen/src/main/resources/lua/api_test.mustache new file mode 100644 index 000000000000..ed57594ee614 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lua/api_test.mustache @@ -0,0 +1,30 @@ +--[[ +{{> partial_header}} +]] + +local petstore_{{classname}} = require "{{packageName}}.api.{{{classname}}}" +{{#models}} +[[-- import all models --]] +{{#model}} +local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}" +{{/model}} +{{/models}} + +--[[ +Unit tests for {{{packageName}}}.api.{{{classname}}} +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +{{#operations}} +describe("{{classname}}", function() +{{#operation}} + -- unit tests for {{operationId}} + describe("{{operationId}} test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +{{/operation}} +end) +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/lua/model_test.mustache b/modules/swagger-codegen/src/main/resources/lua/model_test.mustache new file mode 100644 index 000000000000..a5c43737a28b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/lua/model_test.mustache @@ -0,0 +1,26 @@ +--[[ +{{> partial_header}} +]] + +{{#models}} +{{#model}} +local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}" + +--[[ +Unit tests for {{{packageName}}}.model.{{{classname}}} +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("{{classname}}", function() + {{#vars}} + -- unit tests for the property '{{{name}}}' + describe("property {{{name}}} test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + {{/vars}} +end) +{{/model}} +{{/models}} diff --git a/samples/client/petstore/lua/petstore/spec/api_response_spec.lua b/samples/client/petstore/lua/petstore/spec/api_response_spec.lua new file mode 100644 index 000000000000..106113cf7ca8 --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/api_response_spec.lua @@ -0,0 +1,42 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_api_response = require "petstore.model.api_response" + +--[[ +Unit tests for petstore.model.api_response +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("api_response", function() + -- unit tests for the property 'code' + describe("property code test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'type' + describe("property type test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'message' + describe("property message test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/category_spec.lua b/samples/client/petstore/lua/petstore/spec/category_spec.lua new file mode 100644 index 000000000000..db2d54bcb11e --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/category_spec.lua @@ -0,0 +1,35 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_category = require "petstore.model.category" + +--[[ +Unit tests for petstore.model.category +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("category", function() + -- unit tests for the property 'id' + describe("property id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'name' + describe("property name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/order_spec.lua b/samples/client/petstore/lua/petstore/spec/order_spec.lua new file mode 100644 index 000000000000..2438eeea60ec --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/order_spec.lua @@ -0,0 +1,63 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_order = require "petstore.model.order" + +--[[ +Unit tests for petstore.model.order +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("order", function() + -- unit tests for the property 'id' + describe("property id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'pet_id' + describe("property pet_id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'quantity' + describe("property quantity test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'ship_date' + describe("property ship_date test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'status' + describe("property status test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'complete' + describe("property complete test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/pet_api_spec.lua b/samples/client/petstore/lua/petstore/spec/pet_api_spec.lua new file mode 100644 index 000000000000..4b58ce314b6e --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/pet_api_spec.lua @@ -0,0 +1,77 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_pet_api = require "petstore.api.pet_api" + +--[[ +Unit tests for petstore.api.pet_api +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("pet_api", function() + -- unit tests for add_pet + describe("add_pet test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for delete_pet + describe("delete_pet test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for find_pets_by_status + describe("find_pets_by_status test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for find_pets_by_tags + describe("find_pets_by_tags test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for get_pet_by_id + describe("get_pet_by_id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for update_pet + describe("update_pet test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for update_pet_with_form + describe("update_pet_with_form test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for upload_file + describe("upload_file test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/pet_spec.lua b/samples/client/petstore/lua/petstore/spec/pet_spec.lua new file mode 100644 index 000000000000..0417e3685191 --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/pet_spec.lua @@ -0,0 +1,63 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_pet = require "petstore.model.pet" + +--[[ +Unit tests for petstore.model.pet +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("pet", function() + -- unit tests for the property 'id' + describe("property id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'category' + describe("property category test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'name' + describe("property name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'photo_urls' + describe("property photo_urls test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'tags' + describe("property tags test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'status' + describe("property status test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/store_api_spec.lua b/samples/client/petstore/lua/petstore/spec/store_api_spec.lua new file mode 100644 index 000000000000..c528474c90ae --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/store_api_spec.lua @@ -0,0 +1,49 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_store_api = require "petstore.api.store_api" + +--[[ +Unit tests for petstore.api.store_api +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("store_api", function() + -- unit tests for delete_order + describe("delete_order test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for get_inventory + describe("get_inventory test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for get_order_by_id + describe("get_order_by_id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for place_order + describe("place_order test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/tag_spec.lua b/samples/client/petstore/lua/petstore/spec/tag_spec.lua new file mode 100644 index 000000000000..697f74f0267f --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/tag_spec.lua @@ -0,0 +1,35 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_tag = require "petstore.model.tag" + +--[[ +Unit tests for petstore.model.tag +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("tag", function() + -- unit tests for the property 'id' + describe("property id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'name' + describe("property name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/user_api_spec.lua b/samples/client/petstore/lua/petstore/spec/user_api_spec.lua new file mode 100644 index 000000000000..9c2da762f511 --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/user_api_spec.lua @@ -0,0 +1,77 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_user_api = require "petstore.api.user_api" + +--[[ +Unit tests for petstore.api.user_api +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("user_api", function() + -- unit tests for create_user + describe("create_user test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for create_users_with_array_input + describe("create_users_with_array_input test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for create_users_with_list_input + describe("create_users_with_list_input test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for delete_user + describe("delete_user test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for get_user_by_name + describe("get_user_by_name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for login_user + describe("login_user test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for logout_user + describe("logout_user test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for update_user + describe("update_user test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end) diff --git a/samples/client/petstore/lua/petstore/spec/user_spec.lua b/samples/client/petstore/lua/petstore/spec/user_spec.lua new file mode 100644 index 000000000000..5088acef2fc7 --- /dev/null +++ b/samples/client/petstore/lua/petstore/spec/user_spec.lua @@ -0,0 +1,77 @@ +--[[ +Swagger Petstore + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.4.0-SNAPSHOT + +]] + +local petstore_user = require "petstore.model.user" + +--[[ +Unit tests for petstore.model.user +Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +Please update as you see appropriate +]] +describe("user", function() + -- unit tests for the property 'id' + describe("property id test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'username' + describe("property username test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'first_name' + describe("property first_name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'last_name' + describe("property last_name test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'email' + describe("property email test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'password' + describe("property password test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'phone' + describe("property phone test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + + -- unit tests for the property 'user_status' + describe("property user_status test", function() + it("should work", function() + -- TODO assertion here: http://olivinelabs.com/busted/#asserts + end) + end) + +end)