Skip to content

Commit a52b7c4

Browse files
committed
fix: address review feedback on format and param tests
1 parent 989c4e0 commit a52b7c4

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

t/conformance/test_format_validation.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env resty
22
--- Conformance tests for format keyword validation.
3-
-- Covers uuid, date, date-time, uri, email, ipv4, ipv6, hostname formats.
3+
-- Covers uuid, date, date-time, uri, email, ipv4, hostname formats.
44
-- Each format has positive and negative cases.
55
dofile("t/lib/test_bootstrap.lua")
66

@@ -44,9 +44,7 @@ end
4444
local function validate_format(format_name, value)
4545
local spec = make_format_spec(format_name)
4646
local v, err = ov.compile(spec)
47-
if not v then
48-
return nil, "compile failed: " .. tostring(err)
49-
end
47+
assert(v, "compile failed for format '" .. format_name .. "': " .. tostring(err))
5048
return v:validate_request({
5149
method = "POST",
5250
path = "/test",

t/conformance/test_param_serialization_matrix.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ local ov = require("resty.openapi_validator")
99

1010

1111
local function make_spec(param_def, location)
12+
local param = cjson.decode(cjson.encode(param_def))
1213
local path_template
1314
if location == "path" then
14-
path_template = "/test/{" .. param_def.name .. "}"
15-
param_def.required = true
15+
path_template = "/test/{" .. param.name .. "}"
16+
param.required = true
1617
else
1718
path_template = "/test"
1819
end
@@ -23,7 +24,7 @@ local function make_spec(param_def, location)
2324
paths = {
2425
[path_template] = {
2526
get = {
26-
parameters = { param_def },
27+
parameters = { param },
2728
responses = { ["200"] = { description = "OK" } },
2829
},
2930
},

0 commit comments

Comments
 (0)