Add auto-generated Lua spec files for APIs, models (#7562)

* add auto-generated lua spec files for api, models

* use partial header in test files
This commit is contained in:
William Cheng 2018-02-03 00:12:01 +08:00 committed by GitHub
parent dfbef43743
commit 6c79052ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 595 additions and 15 deletions

View File

@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig { public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
static Logger LOGGER = LoggerFactory.getLogger(LuaClientCodegen.class); static Logger LOGGER = LoggerFactory.getLogger(LuaClientCodegen.class);
protected String specFolder = "spec";
protected String packageName = "swagger-client"; protected String packageName = "swagger-client";
protected String packageVersion = "1.0.0-1"; protected String packageVersion = "1.0.0-1";
protected String apiDocPath = "docs/"; protected String apiDocPath = "docs/";
@ -142,8 +143,8 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath); additionalProperties.put("modelDocPath", modelDocPath);
apiTestTemplateFiles.clear(); // TODO: add api test template apiTestTemplateFiles.put("api_test.mustache", ".lua");
modelTestTemplateFiles.clear(); // TODO: add model test template modelTestTemplateFiles.put("model_test.mustache", ".lua");
apiDocTemplateFiles.clear(); // TODO: add api doc template apiDocTemplateFiles.clear(); // TODO: add api doc template
modelDocTemplateFiles.clear(); // TODO: add model doc template modelDocTemplateFiles.clear(); // TODO: add model doc template
@ -260,6 +261,16 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
return underscore(name) + "_api"; 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". * Overrides postProcessParameter to add a vendor extension "x-exportParamName".
* This is useful when paramName starts with a lowercase letter, but we need that * This is useful when paramName starts with a lowercase letter, but we need that
@ -270,21 +281,16 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public void postProcessParameter(CodegenParameter parameter){ public void postProcessParameter(CodegenParameter parameter){
//// Give the base class a chance to process }
//super.postProcessParameter(parameter);
//char firstChar = parameter.paramName.charAt(0); @Override
public String apiTestFileFolder() {
return outputFolder + File.separator + apiPackage + File.separator + specFolder.replace("/", File.separator);
}
//if (Character.isUpperCase(firstChar)) { @Override
// // First char is already uppercase, just use paramName. public String modelTestFileFolder() {
// parameter.vendorExtensions.put("x-exportParamName", parameter.paramName); return outputFolder + File.separator + modelPackage + 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 @Override

View File

@ -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}}

View File

@ -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}}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)