fix: form fields of request optional (#4755)

Signed-off-by: soasurs <soasurs@gmail.com>
This commit is contained in:
soasurs
2025-04-08 21:05:21 +08:00
committed by GitHub
parent 6f2730d5ae
commit 61641581eb

View File

@@ -57,13 +57,13 @@ func (m Member) Tags() []*Tag {
// IsOptional returns true if tag is optional // IsOptional returns true if tag is optional
func (m Member) IsOptional() bool { func (m Member) IsOptional() bool {
if !m.IsBodyMember() { if !m.IsBodyMember() && !m.IsFormMember() {
return false return false
} }
tag := m.Tags() tag := m.Tags()
for _, item := range tag { for _, item := range tag {
if item.Key == bodyTagKey { if item.Key == bodyTagKey || item.Key == formTagKey {
if stringx.Contains(item.Options, "optional") { if stringx.Contains(item.Options, "optional") {
return true return true
} }