Skip to content

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