diff --git a/apps/emqx_gateway/src/coap/emqx_coap_api.erl b/apps/emqx_gateway/src/coap/emqx_coap_api.erl index e982a6e2c..5c82e6271 100644 --- a/apps/emqx_gateway/src/coap/emqx_coap_api.erl +++ b/apps/emqx_gateway/src/coap/emqx_coap_api.erl @@ -87,19 +87,19 @@ request_parameters() -> [{clientid, mk(binary(), #{in => path, required => true})}]. request_body() -> - [ {token, mk(binary(), #{desc => "message token, can be empty"})} - , {method, mk(enum([get, put, post, delete]), #{desc => "request method type"})} - , {timeout, mk(emqx_schema:duration_ms(), #{desc => "timespan for response"})} + [ {token, mk(binary(), #{description => "message token, can be empty"})} + , {method, mk(enum([get, put, post, delete]), #{description => "request method type"})} + , {timeout, mk(emqx_schema:duration_ms(), #{description => "timespan for response"})} , {content_type, mk(enum(['text/plain', 'application/json', 'application/octet-stream']), - #{desc => "payload type"})} - , {payload, mk(binary(), #{desc => "the content of the payload"})} + #{description => "payload type"})} + , {payload, mk(binary(), #{description => "the content of the payload"})} ]. coap_message() -> - [ {id, mk(integer(), #{desc => "message id"})} - , {token, mk(string(), #{desc => "message token, can be empty"})} - , {method, mk(string(), #{desc => "response code"})} - , {payload, mk(string(), #{desc => "payload"})} + [ {id, mk(integer(), #{description => "message id"})} + , {token, mk(string(), #{description => "message token, can be empty"})} + , {method, mk(string(), #{description => "response code"})} + , {payload, mk(string(), #{description => "payload"})} ]. format_to_response(ContentType, #coap_message{id = Id, diff --git a/apps/emqx_gateway/src/emqx_gateway_api.erl b/apps/emqx_gateway/src/emqx_gateway_api.erl index b3cbcb5b4..2c94dcecb 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api.erl @@ -141,7 +141,7 @@ gateway_insta(put, #{body := GwConf0, end). gateway_insta_stats(get, _Req) -> - return_http_error(401, "Implement it later (maybe 5.1)"). + return_http_error(409, "Implement it later (maybe 5.1)"). %%-------------------------------------------------------------------- %% Swagger defines @@ -197,7 +197,9 @@ schema("/gateway/:name/stats") -> ?STANDARD_RESP( #{200 => emqx_dashboard_swagger:schema_with_examples( ref(gateway_stats), - examples_gateway_stats()) + examples_gateway_stats()), + 409 => emqx_dashboard_swagger:error_codes( + ['NOT_SUPPORT'], <<"Resource not support">>) }) } }. @@ -209,7 +211,7 @@ params_gateway_name_in_path() -> [{name, mk(binary(), #{ in => path - , desc => <<"Gateway Name">> + , description => <<"Gateway Name">> , example => <<"">> })} ]. @@ -220,7 +222,7 @@ params_gateway_status_in_qs() -> mk(binary(), #{ in => query , required => false - , desc => <<"Gateway Status">> + , description => <<"Gateway Status">> , example => <<"">> })} ]. @@ -236,50 +238,50 @@ roots() -> fields(gateway_overview) -> [ {name, mk(binary(), - #{ desc => <<"Gateway Name">>})} + #{ description => <<"Gateway Name">>})} , {status, mk(hoconsc:enum([running, stopped, unloaded]), - #{ desc => <<"The Gateway status">>})} + #{ description => <<"The Gateway status">>})} , {created_at, mk(binary(), - #{desc => <<"The Gateway created datetime">>})} + #{description => <<"The Gateway created datetime">>})} , {started_at, mk(binary(), #{ required => false - , desc => <<"The Gateway started datetime">>})} + , description => <<"The Gateway started datetime">>})} , {stopped_at, mk(binary(), #{ required => false - , desc => <<"The Gateway stopped datetime">>})} + , description => <<"The Gateway stopped datetime">>})} , {max_connections, mk(integer(), - #{ desc => <<"The Gateway allowed maximum connections/clients">>})} + #{ description => <<"The Gateway allowed maximum connections/clients">>})} , {current_connections, mk(integer(), - #{ desc => <<"The Gateway current connected connections/clients">> + #{ description => <<"The Gateway current connected connections/clients">> })} , {listeners, mk(hoconsc:array(ref(gateway_listener_overview)), #{ required => {false, recursively} - , desc => <<"The Gateway listeners overview">>})} + , description => <<"The Gateway listeners overview">>})} ]; fields(gateway_listener_overview) -> [ {id, mk(binary(), - #{ desc => <<"Listener ID">>})} + #{ description => <<"Listener ID">>})} , {running, mk(boolean(), - #{ desc => <<"Listener Running status">>})} + #{ description => <<"Listener Running status">>})} , {type, mk(hoconsc:enum([tcp, ssl, udp, dtls]), - #{ desc => <<"Listener Type">>})} + #{ description => <<"Listener Type">>})} ]; fields(Gw) when Gw == stomp; Gw == mqttsn; Gw == coap; Gw == lwm2m; Gw == exproto -> [{name, - mk(hoconsc:union([Gw]), #{ desc => <<"Gateway Name">>})} + mk(hoconsc:union([Gw]), #{ description => <<"Gateway Name">>})} ] ++ convert_listener_struct(emqx_gateway_schema:fields(Gw)); fields(Gw) when Gw == update_stomp; Gw == update_mqttsn; @@ -296,17 +298,17 @@ fields(Listener) when Listener == tcp_listener; [ {id, mk(binary(), #{ required => false - , desc => <<"Listener ID">>})} + , description => <<"Listener ID">>})} , {type, mk(hoconsc:union([tcp, ssl, udp, dtls]), - #{ desc => <<"Listener type">>})} + #{ description => <<"Listener type">>})} , {name, mk(binary(), - #{ desc => <<"Listener Name">>})} + #{ description => <<"Listener Name">>})} , {running, mk(boolean(), #{ required => false - , desc => <<"Listener running status">>})} + , description => <<"Listener running status">>})} ] ++ emqx_gateway_schema:fields(Listener); fields(gateway_stats) -> @@ -335,7 +337,7 @@ convert_listener_struct(Schema) -> #{type := Type}}, Schema1} = lists:keytake(listeners, 1, Schema), ListenerSchema = hoconsc:mk(listeners_schema(Type), #{ required => {false, recursively} - , desc => <<"The gateway listeners">> + , description => <<"The gateway listeners">> }), lists:keystore(listeners, 1, Schema1, {listeners, ListenerSchema}). diff --git a/apps/emqx_gateway/src/emqx_gateway_api_authn.erl b/apps/emqx_gateway/src/emqx_gateway_api_authn.erl index 240ae5028..837d4a5f5 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api_authn.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api_authn.erl @@ -275,7 +275,7 @@ params_gateway_name_in_path() -> [{name, mk(binary(), #{ in => path - , desc => <<"Gateway Name">> + , description => <<"Gateway Name">> , example => <<"">> })} ]. @@ -283,7 +283,7 @@ params_gateway_name_in_path() -> params_userid_in_path() -> [{uid, mk(binary(), #{ in => path - , desc => <<"User ID">> + , description => <<"User ID">> , example => <<"">> })} ]. @@ -292,13 +292,13 @@ params_paging_in_qs() -> [{page, mk(integer(), #{ in => query , required => false - , desc => <<"Page Index">> + , description => <<"Page Index">> , example => 1 })}, {limit, mk(integer(), #{ in => query , required => false - , desc => <<"Page Limit">> + , description => <<"Page Limit">> , example => 100 })} ]. @@ -308,14 +308,14 @@ params_fuzzy_in_qs() -> mk(binary(), #{ in => query , required => false - , desc => <<"Fuzzy search by username">> + , description => <<"Fuzzy search by username">> , example => <<"username">> })}, {like_clientid, mk(binary(), #{ in => query , required => false - , desc => <<"Fuzzy search by clientid">> + , description => <<"Fuzzy search by clientid">> , example => <<"clientid">> })} ]. diff --git a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl index 01f3458b4..e3e1bd9f7 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api_clients.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api_clients.erl @@ -471,60 +471,60 @@ params_client_searching_in_qs() -> M = #{in => query, required => false, example => <<"">>}, [ {node, mk(binary(), - M#{desc => <<"Match the client's node name">>})} + M#{description => <<"Match the client's node name">>})} , {clientid, mk(binary(), - M#{desc => <<"Match the client's ID">>})} + M#{description => <<"Match the client's ID">>})} , {username, mk(binary(), - M#{desc => <<"Match the client's Username">>})} + M#{description => <<"Match the client's Username">>})} , {ip_address, mk(binary(), - M#{desc => <<"Match the client's ip address">>})} + M#{description => <<"Match the client's ip address">>})} , {conn_state, mk(binary(), - M#{desc => <<"Match the client's connection state">>})} + M#{description => <<"Match the client's connection state">>})} , {proto_ver, mk(binary(), - M#{desc => <<"Match the client's protocol version">>})} + M#{description => <<"Match the client's protocol version">>})} , {clean_start, mk(boolean(), - M#{desc => <<"Match the client's clean start flag">>})} + M#{description => <<"Match the client's clean start flag">>})} , {like_clientid, mk(binary(), - M#{desc => <<"Use sub-string to match client's ID">>})} + M#{description => <<"Use sub-string to match client's ID">>})} , {like_username, mk(binary(), - M#{desc => <<"Use sub-string to match client's username">>})} + M#{description => <<"Use sub-string to match client's username">>})} , {gte_created_at, mk(emqx_datetime:epoch_millisecond(), - M#{desc => <<"Match the session created datetime greater than " + M#{description => <<"Match the session created datetime greater than " "a certain value">>})} , {lte_created_at, mk(emqx_datetime:epoch_millisecond(), - M#{desc => <<"Match the session created datetime less than " + M#{description => <<"Match the session created datetime less than " "a certain value">>})} , {gte_connected_at, mk(emqx_datetime:epoch_millisecond(), - M#{desc => <<"Match the client socket connected datetime greater " + M#{description => <<"Match the client socket connected datetime greater " "than a certain value">>})} , {lte_connected_at, mk(emqx_datetime:epoch_millisecond(), - M#{desc => <<"Match the client socket connected datatime less than " + M#{description => <<"Match the client socket connected datatime less than " "a certain value">>})} , {endpoint_name, mk(binary(), - M#{desc => <<"Match the lwm2m client's endpoint name">>})} + M#{description => <<"Match the lwm2m client's endpoint name">>})} , {like_endpoint_name, mk(binary(), - M#{desc => <<"Use sub-string to match lwm2m client's endpoint name">>})} + M#{description => <<"Use sub-string to match lwm2m client's endpoint name">>})} , {gte_lifetime, mk(binary(), - M#{desc => <<"Match the lwm2m client registered lifetime greater " + M#{description => <<"Match the lwm2m client registered lifetime greater " "than a certain value">>})} , {lte_lifetime, mk(binary(), - M#{desc => <<"Match the lwm2m client registered lifetime less than " + M#{description => <<"Match the lwm2m client registered lifetime less than " "a certain value">>})} ]. @@ -533,13 +533,13 @@ params_paging() -> mk(integer(), #{ in => query , required => false - , desc => <<"Page Index">> + , description => <<"Page Index">> , example => 1 })} , {limit, mk(integer(), #{ in => query - , desc => <<"Page Limit">> + , description => <<"Page Limit">> , required => false , example => 100 })} @@ -549,7 +549,7 @@ params_gateway_name_in_path() -> [{name, mk(binary(), #{ in => path - , desc => <<"Gateway Name">> + , description => <<"Gateway Name">> })} ]. @@ -557,7 +557,7 @@ params_clientid_in_path() -> [{clientid, mk(binary(), #{ in => path - , desc => <<"Client ID">> + , description => <<"Client ID">> })} ]. @@ -565,7 +565,7 @@ params_topic_name_in_path() -> [{topic, mk(binary(), #{ in => path - , desc => <<"Topic Filter/Name">> + , description => <<"Topic Filter/Name">> })} ]. @@ -612,10 +612,10 @@ fields(coap_client) -> fields(lwm2m_client) -> [ {endpoint_name, mk(binary(), - #{ desc => <<"The LwM2M client endpoint name">>})} + #{ description => <<"The LwM2M client endpoint name">>})} , {lifetime, mk(integer(), - #{ desc => <<"Life time">>})} + #{ description => <<"Life time">>})} ] ++ common_client_props(); fields(exproto_client) -> common_client_props(); @@ -623,153 +623,153 @@ fields(exproto_client) -> fields(subscription) -> [ {topic, mk(binary(), - #{ desc => <<"Topic Fillter">>})} + #{ description => <<"Topic Fillter">>})} , {qos, mk(integer(), - #{ desc => <<"QoS level, enum: 0, 1, 2">>})} + #{ description => <<"QoS level, enum: 0, 1, 2">>})} , {nl, mk(integer(), %% FIXME: why not boolean? - #{ desc => <<"No Local option, enum: 0, 1">>})} + #{ description => <<"No Local option, enum: 0, 1">>})} , {rap, mk(integer(), - #{ desc => <<"Retain as Published option, enum: 0, 1">>})} + #{ description => <<"Retain as Published option, enum: 0, 1">>})} , {rh, mk(integer(), - #{ desc => <<"Retain Handling option, enum: 0, 1, 2">>})} + #{ description => <<"Retain Handling option, enum: 0, 1, 2">>})} , {sub_props, mk(ref(extra_sub_props), - #{desc => <<"Subscription properties">>})} + #{description => <<"Subscription properties">>})} ]; fields(extra_sub_props) -> [ {subid, mk(binary(), - #{ desc => <<"Only stomp protocol, a unique identity for " + #{ description => <<"Only stomp protocol, a unique identity for " "the subscription. range: 1-65535.">>})} ]. common_client_props() -> [ {node, mk(binary(), - #{ desc => <<"Name of the node to which the client is " + #{ description => <<"Name of the node to which the client is " "connected">>})} , {clientid, mk(binary(), - #{ desc => <<"Client identifier">>})} + #{ description => <<"Client identifier">>})} , {username, mk(binary(), - #{ desc => <<"Username of client when connecting">>})} + #{ description => <<"Username of client when connecting">>})} , {proto_name, mk(binary(), - #{ desc => <<"Client protocol name">>})} + #{ description => <<"Client protocol name">>})} , {proto_ver, mk(binary(), - #{ desc => <<"Protocol version used by the client">>})} + #{ description => <<"Protocol version used by the client">>})} , {ip_address, mk(binary(), - #{ desc => <<"Client's IP address">>})} + #{ description => <<"Client's IP address">>})} , {port, mk(integer(), - #{ desc => <<"Client's port">>})} + #{ description => <<"Client's port">>})} , {is_bridge, mk(boolean(), - #{ desc => <<"Indicates whether the client is connected via " + #{ description => <<"Indicates whether the client is connected via " "bridge">>})} , {connected_at, mk(emqx_datetime:epoch_millisecond(), - #{ desc => <<"Client connection time">>})} + #{ description => <<"Client connection time">>})} , {disconnected_at, mk(emqx_datetime:epoch_millisecond(), - #{ desc => <<"Client offline time, This field is only valid and " + #{ description => <<"Client offline time, This field is only valid and " "returned when connected is false">>})} , {connected, mk(boolean(), - #{ desc => <<"Whether the client is connected">>})} + #{ description => <<"Whether the client is connected">>})} %% FIXME: the will_msg attribute is not a general attribute %% for every protocol. But it should be returned to frontend if someone %% want it %% %, {will_msg, % mk(binary(), - % #{ desc => <<"Client will message">>})} + % #{ description => <<"Client will message">>})} , {keepalive, mk(integer(), - #{ desc => <<"keepalive time, with the unit of second">>})} + #{ description => <<"keepalive time, with the unit of second">>})} , {clean_start, mk(boolean(), - #{ desc => <<"Indicate whether the client is using a brand " + #{ description => <<"Indicate whether the client is using a brand " "new session">>})} , {expiry_interval, mk(integer(), - #{ desc => <<"Session expiration interval, with the unit of " + #{ description => <<"Session expiration interval, with the unit of " "second">>})} , {created_at, mk(emqx_datetime:epoch_millisecond(), - #{ desc => <<"Session creation time">>})} + #{ description => <<"Session creation time">>})} , {subscriptions_cnt, mk(integer(), - #{ desc => <<"Number of subscriptions established by this " + #{ description => <<"Number of subscriptions established by this " "client">>})} , {subscriptions_max, mk(integer(), - #{ desc => <<"Maximum number of subscriptions allowed by this " + #{ description => <<"Maximum number of subscriptions allowed by this " "client">>})} , {inflight_cnt, mk(integer(), - #{ desc => <<"Current length of inflight">>})} + #{ description => <<"Current length of inflight">>})} , {inflight_max, mk(integer(), - #{ desc => <<"Maximum length of inflight">>})} + #{ description => <<"Maximum length of inflight">>})} , {mqueue_len, mk(integer(), - #{ desc => <<"Current length of message queue">>})} + #{ description => <<"Current length of message queue">>})} , {mqueue_max, mk(integer(), - #{ desc => <<"Maximum length of message queue">>})} + #{ description => <<"Maximum length of message queue">>})} , {mqueue_dropped, mk(integer(), - #{ desc => <<"Number of messages dropped by the message queue " + #{ description => <<"Number of messages dropped by the message queue " "due to exceeding the length">>})} , {awaiting_rel_cnt, mk(integer(), %% FIXME: PUBREC ?? - #{ desc => <<"Number of awaiting acknowledge packet">>})} + #{ description => <<"Number of awaiting acknowledge packet">>})} , {awaiting_rel_max, mk(integer(), - #{ desc => <<"Maximum allowed number of awaiting PUBREC " + #{ description => <<"Maximum allowed number of awaiting PUBREC " "packet">>})} , {recv_oct, mk(integer(), - #{ desc => <<"Number of bytes received">>})} + #{ description => <<"Number of bytes received">>})} , {recv_cnt, mk(integer(), - #{ desc => <<"Number of socket packets received">>})} + #{ description => <<"Number of socket packets received">>})} , {recv_pkt, mk(integer(), - #{ desc => <<"Number of protocol packets received">>})} + #{ description => <<"Number of protocol packets received">>})} , {recv_msg, mk(integer(), - #{ desc => <<"Number of message packets received">>})} + #{ description => <<"Number of message packets received">>})} , {send_oct, mk(integer(), - #{ desc => <<"Number of bytes sent">>})} + #{ description => <<"Number of bytes sent">>})} , {send_cnt, mk(integer(), - #{ desc => <<"Number of socket packets sent">>})} + #{ description => <<"Number of socket packets sent">>})} , {send_pkt, mk(integer(), - #{ desc => <<"Number of protocol packets sent">>})} + #{ description => <<"Number of protocol packets sent">>})} , {send_msg, mk(integer(), - #{ desc => <<"Number of message packets sent">>})} + #{ description => <<"Number of message packets sent">>})} , {mailbox_len, mk(integer(), - #{ desc => <<"Process mailbox size">>})} + #{ description => <<"Process mailbox size">>})} , {heap_size, mk(integer(), - #{ desc => <<"Process heap size with the unit of byte">>})} + #{ description => <<"Process heap size with the unit of byte">>})} , {reductions, mk(integer(), - #{ desc => <<"Erlang reduction">>})} + #{ description => <<"Erlang reduction">>})} ]. %%-------------------------------------------------------------------- diff --git a/apps/emqx_gateway/src/emqx_gateway_api_listeners.erl b/apps/emqx_gateway/src/emqx_gateway_api_listeners.erl index 61285082f..e0bc3c8df 100644 --- a/apps/emqx_gateway/src/emqx_gateway_api_listeners.erl +++ b/apps/emqx_gateway/src/emqx_gateway_api_listeners.erl @@ -409,7 +409,7 @@ params_gateway_name_in_path() -> [{name, mk(binary(), #{ in => path - , desc => <<"Gateway Name">> + , description => <<"Gateway Name">> , example => <<"">> })} ]. @@ -418,7 +418,7 @@ params_listener_id_in_path() -> [{id, mk(binary(), #{ in => path - , desc => <<"Listener ID">> + , description => <<"Listener ID">> , example => <<"">> })} ]. @@ -426,7 +426,7 @@ params_listener_id_in_path() -> params_userid_in_path() -> [{uid, mk(binary(), #{ in => path - , desc => <<"User ID">> + , description => <<"User ID">> , example => <<"">> })} ]. @@ -435,13 +435,13 @@ params_paging_in_qs() -> [{page, mk(integer(), #{ in => query , required => false - , desc => <<"Page Index">> + , description => <<"Page Index">> , example => 1 })}, {limit, mk(integer(), #{ in => query , required => false - , desc => <<"Page Limit">> + , description => <<"Page Limit">> , example => 100 })} ]. @@ -458,22 +458,22 @@ fields(listener) -> [ {tcp, mk(ref(tcp_listener_opts), #{ required => {false, recursively} - , desc => <<"The tcp socket options for tcp or ssl listener">> + , description => <<"The tcp socket options for tcp or ssl listener">> })} , {ssl, mk(ref(ssl_listener_opts), #{ required => {false, recursively} - , desc => <<"The ssl socket options for ssl listener">> + , description => <<"The ssl socket options for ssl listener">> })} , {udp, mk(ref(udp_listener_opts), #{ required => {false, recursively} - , desc => <<"The udp socket options for udp or dtls listener">> + , description => <<"The udp socket options for udp or dtls listener">> })} , {dtls, mk(ref(dtls_listener_opts), #{ required => {false, recursively} - , desc => <<"The dtls socket options for dtls listener">> + , description => <<"The dtls socket options for dtls listener">> })} ]; fields(tcp_listener_opts) -> @@ -530,47 +530,47 @@ common_listener_opts() -> [ {enable, mk(boolean(), #{ required => false - , desc => <<"Whether to enable this listener">>})} + , description => <<"Whether to enable this listener">>})} , {id, mk(binary(), #{ required => false - , desc => <<"Listener Id">>})} + , description => <<"Listener Id">>})} , {name, mk(binary(), #{ required => false - , desc => <<"Listener name">>})} + , description => <<"Listener name">>})} , {type, mk(hoconsc:enum([tcp, ssl, udp, dtls]), #{ required => false - , desc => <<"Listener type. Enum: tcp, udp, ssl, dtls">>})} + , description => <<"Listener type. Enum: tcp, udp, ssl, dtls">>})} , {running, mk(boolean(), #{ required => false - , desc => <<"Listener running status">>})} + , description => <<"Listener running status">>})} , {bind, mk(binary(), #{ required => false - , desc => <<"Listener bind address or port">>})} + , description => <<"Listener bind address or port">>})} , {acceptors, mk(integer(), #{ required => false - , desc => <<"Listener acceptors number">>})} + , description => <<"Listener acceptors number">>})} , {access_rules, mk(hoconsc:array(binary()), #{ required => false - , desc => <<"Listener Access rules for client">>})} + , description => <<"Listener Access rules for client">>})} , {max_conn_rate, mk(integer(), #{ required => false - , desc => <<"Max connection rate for the listener">>})} + , description => <<"Max connection rate for the listener">>})} , {max_connections, mk(integer(), #{ required => false - , desc => <<"Max connections for the listener">>})} + , description => <<"Max connections for the listener">>})} , {mountpoint, mk(binary(), #{ required => false - , desc => + , description => <<"The Mounpoint for clients of the listener. " "The gateway-level mountpoint configuration can be overloaded " "when it is not null or empty string">>})} @@ -578,7 +578,7 @@ common_listener_opts() -> , {authentication, mk(emqx_authn_schema:authenticator_type(), #{ required => {false, recursively} - , desc => <<"The authenticatior for this listener">> + , description => <<"The authenticatior for this listener">> })} ] ++ emqx_gateway_schema:proxy_protocol_opts(). diff --git a/apps/emqx_gateway/src/emqx_gateway_http.erl b/apps/emqx_gateway/src/emqx_gateway_http.erl index e0795c950..0f83a4374 100644 --- a/apps/emqx_gateway/src/emqx_gateway_http.erl +++ b/apps/emqx_gateway/src/emqx_gateway_http.erl @@ -307,11 +307,7 @@ reason2resp(R) -> -spec return_http_error(integer(), any()) -> {integer(), binary()}. return_http_error(Code, Msg) -> - {Code, emqx_json:encode( - #{code => codestr(Code), - message => emqx_gateway_utils:stringfy(Msg) - }) - }. + {Code, codestr(Code), emqx_gateway_utils:stringfy(Msg)}. -spec reason2msg({atom(), map()} | any()) -> error | string(). reason2msg({badconf, #{key := Key, value := Value, reason := Reason}}) -> @@ -362,9 +358,9 @@ reason2msg(_) -> error. codestr(400) -> 'BAD_REQUEST'; -codestr(401) -> 'NOT_SUPPORTED_NOW'; codestr(404) -> 'RESOURCE_NOT_FOUND'; codestr(405) -> 'METHOD_NOT_ALLOWED'; +codestr(409) -> 'NOT_SUPPORT'; codestr(500) -> 'UNKNOW_ERROR'; codestr(501) -> 'NOT_IMPLEMENTED'. diff --git a/apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl b/apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl index 875bcc691..64455e5ae 100644 --- a/apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl +++ b/apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl @@ -117,11 +117,11 @@ schema(?PATH("/write")) -> fields(resource) -> [ - {operations, mk(binary(), #{desc => <<"Resource Operations">>, example => "E"})}, - {'dataType', mk(hoconsc:enum(?DATA_TYPE), #{desc => <<"Data Type">>, + {operations, mk(binary(), #{description => <<"Resource Operations">>, example => "E"})}, + {'dataType', mk(hoconsc:enum(?DATA_TYPE), #{description => <<"Data Type">>, example => 'Integer'})}, - {path, mk(binary(), #{desc => <<"Resource Path">>, example => "urn:oma:lwm2m:oma:2"})}, - {name, mk(binary(), #{desc => <<"Resource Name">>, example => "lwm2m-test"})} + {path, mk(binary(), #{description => <<"Resource Path">>, example => "urn:oma:lwm2m:oma:2"})}, + {name, mk(binary(), #{description => <<"Resource Name">>, example => "lwm2m-test"})} ]. lookup_cmd(get, #{bindings := Bindings, query_string := QS}) ->