Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix go validator in api #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix go validator in api #72

wants to merge 1 commit into from

Conversation

dxyinme
Copy link

@dxyinme dxyinme commented Mar 17, 2023

I found a bug if I use validator in *.api file. This plugin will generate the illegal swagger file like this.

        // API body
	AddTaskTypeReq {
		SessionId         string `json:"session_id"`
		Name              string `json:"name" validate:"gte=1,lte=64"`
		MaxTaskInQueLimit int64  `json:"max_task_in_que_limit" validate:"min=-1,max=100000"`
		ExtraInfo         string `json:"extra_info,optional"`
	}

swagger json

"AddTaskTypeReq": {
      "type": "object",
      "properties": {
        "session_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "max_task_in_que_limit": {
          "type": "integer",
          "format": "int64"
        },
        "extra_info": {
          "type": "string"
        }
      },
      "title": "AddTaskTypeReq",
      "required": [
        "session_id",
        "name",
        "gte=1",
        "max_task_in_que_limit",
        "min=-1"
      ]
    }

the gte=1 and min=-1 in output file is unexpected.
so I create a PR to fix this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant