Skip to content

Commit

Permalink
fix(request): anticipate operations with no inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Mar 19, 2024
1 parent f6a4468 commit 99762dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/resty/aws/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,16 @@ local function generate_service_methods(service)
method_name)

service[method_name] = function(self, params)
params = params or {}

--print(require("pl.pretty").write(self.config))

-- validate parameters
local ok, err = validate_input(params, operation.input, "params")
if not ok then
return nil, operation_prefix .. " validation error: " .. tostring(err)
-- validate parameters if we have any; eg. S3 "listBuckets" has none
if operation.input then
local ok, err = validate_input(params, operation.input, "params")
if not ok then
return nil, operation_prefix .. " validation error: " .. tostring(err)
end
end

-- implement stsRegionalEndpoints config setting,
Expand Down
2 changes: 1 addition & 1 deletion src/resty/aws/request/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ local function build_request(operation, config, params)

-- inject parameters in the right places; path/query/header/body
-- this assumes they all live on the top-level of the structure, is this correct??
for name, member_config in pairs(operation.input.members) do
for name, member_config in pairs((operation.input or {}).members or {}) do
local param_value = params[name]
-- TODO: date-time value should be properly formatted???
if param_value ~= nil then
Expand Down

0 comments on commit 99762dd

Please sign in to comment.