Skip to content

Commit dbe78e2

Browse files
authored
[Lua] Improve auto-generated test files (#7568)
* move lua spec folder, remove extra endline * remove extra line * remove duplicated import
1 parent 6c79052 commit dbe78e2

File tree

12 files changed

+90
-118
lines changed

12 files changed

+90
-118
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/LuaClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ public void postProcessParameter(CodegenParameter parameter){
285285

286286
@Override
287287
public String apiTestFileFolder() {
288-
return outputFolder + File.separator + apiPackage + File.separator + specFolder.replace("/", File.separator);
288+
return outputFolder + File.separator + specFolder.replace("/", File.separator);
289289
}
290290

291291
@Override
292292
public String modelTestFileFolder() {
293-
return outputFolder + File.separator + modelPackage + File.separator + specFolder.replace("/", File.separator);
293+
return outputFolder + File.separator + specFolder.replace("/", File.separator);
294294
}
295295

296296
@Override

modules/swagger-codegen/src/main/resources/lua/api_test.mustache

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
--[[
21
{{> partial_header}}
3-
]]
4-
5-
local petstore_{{classname}} = require "{{packageName}}.api.{{{classname}}}"
6-
{{#models}}
7-
[[-- import all models --]]
8-
{{#model}}
9-
local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}"
10-
{{/model}}
11-
{{/models}}
12-
132
--[[
143
Unit tests for {{{packageName}}}.api.{{{classname}}}
154
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
165
Please update as you see appropriate
176
]]
187
{{#operations}}
198
describe("{{classname}}", function()
9+
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.api.{{{classname}}}"
2010
{{#operation}}
11+
{{#models}}
12+
[[-- import all models --]]
13+
{{#model}}
14+
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
15+
{{/model}}
16+
{{/models}}
2117
-- unit tests for {{operationId}}
22-
describe("{{operationId}} test", function()
18+
describe("{{{operationId}}} test", function()
2319
it("should work", function()
2420
-- TODO assertion here: http://olivinelabs.com/busted/#asserts
2521
end)

modules/swagger-codegen/src/main/resources/lua/model_test.mustache

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
--[[
21
{{> partial_header}}
3-
]]
4-
52
{{#models}}
63
{{#model}}
7-
local {{packageName}}_{{{classname}}} = require "{{packageName}}.model.{{{classname}}}"
8-
94
--[[
105
Unit tests for {{{packageName}}}.model.{{{classname}}}
116
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
127
Please update as you see appropriate
138
]]
149
describe("{{classname}}", function()
10+
local {{{packageName}}}_{{{classname}}} = require "{{{packageName}}}.model.{{{classname}}}"
11+
1512
{{#vars}}
1613
-- unit tests for the property '{{{name}}}'
1714
describe("property {{{name}}} test", function()

samples/client/petstore/lua/petstore/spec/api_response_spec.lua renamed to samples/client/petstore/lua/spec/api_response_spec.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_api_response = require "petstore.model.api_response"
14-
1511
--[[
1612
Unit tests for petstore.model.api_response
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("api_response", function()
17+
local petstore_api_response = require "petstore.model.api_response"
18+
2119
-- unit tests for the property 'code'
2220
describe("property code test", function()
2321
it("should work", function()

samples/client/petstore/lua/petstore/spec/category_spec.lua renamed to samples/client/petstore/lua/spec/category_spec.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_category = require "petstore.model.category"
14-
1511
--[[
1612
Unit tests for petstore.model.category
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("category", function()
17+
local petstore_category = require "petstore.model.category"
18+
2119
-- unit tests for the property 'id'
2220
describe("property id test", function()
2321
it("should work", function()

samples/client/petstore/lua/petstore/spec/order_spec.lua renamed to samples/client/petstore/lua/spec/order_spec.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_order = require "petstore.model.order"
14-
1511
--[[
1612
Unit tests for petstore.model.order
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("order", function()
17+
local petstore_order = require "petstore.model.order"
18+
2119
-- unit tests for the property 'id'
2220
describe("property id test", function()
2321
it("should work", function()

samples/client/petstore/lua/petstore/spec/pet_api_spec.lua renamed to samples/client/petstore/lua/spec/pet_api_spec.lua

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_pet_api = require "petstore.api.pet_api"
14-
1511
--[[
1612
Unit tests for petstore.api.pet_api
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("pet_api", function()
17+
local petstore_pet_api = require "petstore.api.pet_api"
2118
-- unit tests for add_pet
2219
describe("add_pet test", function()
2320
it("should work", function()

samples/client/petstore/lua/petstore/spec/pet_spec.lua renamed to samples/client/petstore/lua/spec/pet_spec.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_pet = require "petstore.model.pet"
14-
1511
--[[
1612
Unit tests for petstore.model.pet
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("pet", function()
17+
local petstore_pet = require "petstore.model.pet"
18+
2119
-- unit tests for the property 'id'
2220
describe("property id test", function()
2321
it("should work", function()

samples/client/petstore/lua/petstore/spec/store_api_spec.lua renamed to samples/client/petstore/lua/spec/store_api_spec.lua

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_store_api = require "petstore.api.store_api"
14-
1511
--[[
1612
Unit tests for petstore.api.store_api
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("store_api", function()
17+
local petstore_store_api = require "petstore.api.store_api"
2118
-- unit tests for delete_order
2219
describe("delete_order test", function()
2320
it("should work", function()

samples/client/petstore/lua/petstore/spec/tag_spec.lua renamed to samples/client/petstore/lua/spec/tag_spec.lua

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
--[[
2-
Swagger Petstore
3-
4-
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.
5-
6-
OpenAPI spec version: 1.0.0
7-
Contact: apiteam@swagger.io
8-
Generated by: https://github.com/swagger-api/swagger-codegen.git
9-
Swagger Codegen version: 2.4.0-SNAPSHOT
10-
2+
Swagger Petstore
3+
4+
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.
5+
6+
OpenAPI spec version: 1.0.0
7+
Contact: apiteam@swagger.io
8+
Generated by: https://github.com/swagger-api/swagger-codegen.git
119
]]
1210

13-
local petstore_tag = require "petstore.model.tag"
14-
1511
--[[
1612
Unit tests for petstore.model.tag
1713
Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
1814
Please update as you see appropriate
1915
]]
2016
describe("tag", function()
17+
local petstore_tag = require "petstore.model.tag"
18+
2119
-- unit tests for the property 'id'
2220
describe("property id test", function()
2321
it("should work", function()

0 commit comments

Comments
 (0)