swag icon indicating copy to clipboard operation
swag copied to clipboard

Swag does not compatible with the `dive` rule of Go Playground Validator

Open ansidev opened this issue 3 years ago • 0 comments

Describe the bug Swag does not compatible with the dive rule of Go Playground Validator

To Reproduce

I have a JSON request model

type SampleRequest struct {
	items []string `json:"items" validate:"omitempty,dive,required"`
}

The validate tag is from the Go Playground Validator (reference link for the rule dive). This means that the items key is optional, but if it is included in the JSON request, the required rule will be applied to elements of items.

Actual Behavior

  • The generated Swagger documentation shows that the items key is a required field.

Expected behavior

  • The generated Swagger documentation shows that the items key is an optional field.

Your swag version

1.8.3

Your go version

1.18.3 darwin/amd64

Desktop (please complete the following information):

  • OS: macOS Monterey 12.4
  • Browser: Google Chrome 103.0.5060.114 (Official Build) (x86_64)

ansidev avatar Jul 12 '22 03:07 ansidev