fix(plugin): allow duplicate parameter names across different locations #2165
+14
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the plugin parameter validation logic to allow duplicate
parameter names across different locations while maintaining uniqueness within
the same location.
Changes:
same location
What type of PR is this?
fix: A bug fix
Check the PR title.
<description>
others to understand.
level.
(Optional) Translate the PR title into Chinese.
fix(plugin): 允许不同位置的参数名称重复
(Optional) More detailed description for this PR(en: English/zh:
Chinese).
en:
Previously, the plugin configuration system prevented users from using the
same parameter name in different locations (e.g., having a "token" parameter
in both request headers and request body). This was overly restrictive and
blocked legitimate use cases.
This PR implements a "location + name" combined validation approach:
checkSameNamefunction to include location filtering(
dataItem.name === val && dataItem.location === item.location)instead of just parameter names
(Header, Body, Query, Path)
zh(optional):
之前的插件配置系统阻止用户在不同位置使用相同的参数名称(例如在请求头和请求体中
都有"token"参数),这种限制过于严格,阻碍了合理的使用场景。
此PR实现了"位置+名称"联合验证方法:
checkSameName函数,增加位置过滤(dataItem.name === val && dataItem.location === item.location)(Optional) Which issue(s) this PR fixes:
Fixes the "参数名称不能重复" (parameter names cannot be duplicated) error that
incorrectly triggered when users had legitimate use cases requiring the same
parameter name in different request locations.