fix(gw): fix bad paging params
This commit is contained in:
parent
7d9930b64e
commit
4eb27ce25b
|
@ -82,6 +82,7 @@ authn(get, #{bindings := #{name := Name0}}) ->
|
|||
authn(put, #{bindings := #{name := Name0},
|
||||
body := Body}) ->
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
%% TODO: return the authn instances?
|
||||
ok = emqx_gateway_http:update_authn(GwName, Body),
|
||||
{204}
|
||||
end);
|
||||
|
@ -89,6 +90,7 @@ authn(put, #{bindings := #{name := Name0},
|
|||
authn(post, #{bindings := #{name := Name0},
|
||||
body := Body}) ->
|
||||
with_gateway(Name0, fun(GwName, _) ->
|
||||
%% TODO: return the authn instances?
|
||||
ok = emqx_gateway_http:add_authn(GwName, Body),
|
||||
{204}
|
||||
end);
|
||||
|
@ -210,7 +212,8 @@ schema("/gateway/:name/authentication/users") ->
|
|||
#{ 'operationId' => users
|
||||
, get =>
|
||||
#{ description => <<"Get the users for the authentication">>
|
||||
, parameters => params_gateway_name_in_path()
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_paging_in_qs()
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -224,6 +227,9 @@ schema("/gateway/:name/authentication/users") ->
|
|||
post =>
|
||||
#{ description => <<"Add user for the authentication">>
|
||||
, parameters => params_gateway_name_in_path()
|
||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||
ref(emqx_authn_api, request_user_create),
|
||||
emqx_authn_api:request_user_create_examples())
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -257,6 +263,9 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
|||
"authentication">>
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_userid_in_path()
|
||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||
ref(emqx_authn_api, request_user_update),
|
||||
emqx_authn_api:request_user_update_examples())
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -271,8 +280,7 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
|||
#{ description => <<"Delete the user for the gateway "
|
||||
"authentication">>
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_userid_in_path() ++
|
||||
params_paging_in_qs()
|
||||
params_userid_in_path()
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -325,10 +333,12 @@ params_userid_in_path() ->
|
|||
params_paging_in_qs() ->
|
||||
[{page, mk(integer(),
|
||||
#{ in => query
|
||||
, desc => <<"Page Number">>
|
||||
, nullable => true
|
||||
, desc => <<"Page Index">>
|
||||
})},
|
||||
{limit, mk(integer(),
|
||||
#{ in => query
|
||||
, nullable => true
|
||||
, desc => <<"Page Limit">>
|
||||
})}
|
||||
].
|
||||
|
|
|
@ -353,7 +353,8 @@ schema("/gateway/:name/listeners/:id/authentication/users") ->
|
|||
, get =>
|
||||
#{ description => <<"Get the users for the authentication">>
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_listener_id_in_path()
|
||||
params_listener_id_in_path() ++
|
||||
params_paging_in_qs()
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -368,6 +369,9 @@ schema("/gateway/:name/listeners/:id/authentication/users") ->
|
|||
#{ description => <<"Add user for the authentication">>
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_listener_id_in_path()
|
||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||
ref(emqx_authn_api, request_user_create),
|
||||
emqx_authn_api:request_user_create_examples())
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -403,6 +407,9 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
|||
, parameters => params_gateway_name_in_path() ++
|
||||
params_listener_id_in_path() ++
|
||||
params_userid_in_path()
|
||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||
ref(emqx_authn_api, request_user_update),
|
||||
emqx_authn_api:request_user_update_examples())
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -418,8 +425,7 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
|||
"authentication">>
|
||||
, parameters => params_gateway_name_in_path() ++
|
||||
params_listener_id_in_path() ++
|
||||
params_userid_in_path() ++
|
||||
params_paging_in_qs()
|
||||
params_userid_in_path()
|
||||
, responses =>
|
||||
#{ 400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||
, 404 => error_codes([?NOT_FOUND], <<"Not Found">>)
|
||||
|
@ -481,10 +487,12 @@ params_userid_in_path() ->
|
|||
params_paging_in_qs() ->
|
||||
[{page, mk(integer(),
|
||||
#{ in => query
|
||||
, desc => <<"Page Number">>
|
||||
, nullable => true
|
||||
, desc => <<"Page Index">>
|
||||
})},
|
||||
{limit, mk(integer(),
|
||||
#{ in => query
|
||||
, nullable => true
|
||||
, desc => <<"Page Limit">>
|
||||
})}
|
||||
].
|
||||
|
@ -630,7 +638,7 @@ common_listener_opts() ->
|
|||
%% examples
|
||||
|
||||
examples_listener_list() ->
|
||||
[examples_listener()].
|
||||
#{stomp_listeners => [examples_listener()]}.
|
||||
|
||||
examples_listener() ->
|
||||
#{id => true}.
|
||||
#{}.
|
||||
|
|
|
@ -328,7 +328,7 @@ codestr(500) -> 'UNKNOW_ERROR'.
|
|||
|
||||
-spec with_authn(binary(), function()) -> any().
|
||||
with_authn(GwName0, Fun) ->
|
||||
with_gateway(GwName0, fun(GwName) ->
|
||||
with_gateway(GwName0, fun(GwName, _GwConf) ->
|
||||
Authn = emqx_gateway_http:authn(GwName),
|
||||
Fun(GwName, Authn)
|
||||
end).
|
||||
|
|
Loading…
Reference in New Issue