apisix icon indicating copy to clipboard operation
apisix copied to clipboard

help request: customize error msg when using `request-validation` plugin for validation

Open shuqingzai opened this issue 3 years ago • 7 comments
trafficstars

Description

request-validation 插件作为验证,是否可以为 字段 自定义错误信息 如: title 我想显示 标题不正确 我似乎没有找到相关的文档 apache/apisix-dashboard#2479

Environment

官方docker镜像: apache/apisix:2.14.1-centos

docker pull apache/apisix:2.14.1-centos
  • APISIX version (run apisix version):
    /usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version 2.14.1
    
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
    v2.13
    
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

shuqingzai avatar Jun 22 '22 05:06 shuqingzai

try: https://github.com/apache/apisix/blob/master/docs/en/latest/terminology/plugin.md#plugin-common-configuration

tzssangglass avatar Jun 22 '22 06:06 tzssangglass

try: https://github.com/apache/apisix/blob/master/docs/en/latest/terminology/plugin.md#plugin-common-configuration

这个作用域好像是建立在插件上,但是如何给出验证不过的字段然后定义错误信息呢? 如下

  1. title 不正确,我想给出的提示语: 标题不正确
  2. description 不正确,我想给出的提示语: 描述信息错误

shuqingzai avatar Jun 22 '22 10:06 shuqingzai

这个作用域好像是建立在插件上,但是如何给出验证不过的字段然后定义错误信息呢? 如下

  1. title 不正确,我想给出的提示语: 标题不正确
  2. description 不正确,我想给出的提示语: 描述信息错误

I remember that jsonschema validation failure can give details, so maybe we can throw out the details.

tzssangglass avatar Jun 22 '22 11:06 tzssangglass

I remember that jsonschema validation failure can give details, so maybe we can throw out the details.

Maybe we can take care of this detailed information.

tzssangglass avatar Jun 22 '22 11:06 tzssangglass

IMHO The JSON schema validation failure error message is not so straightforward and it's lenthy.

tokers avatar Jun 23 '22 01:06 tokers

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Jun 08 '23 10:06 github-actions[bot]

这个 issue 是否活跃?

shuqingzai avatar Jun 09 '23 01:06 shuqingzai