Remove the repeated Required tag
This commit is contained in:
parent
05cdea3e7c
commit
80775cf7ef
@ -18,7 +18,6 @@ type (
|
||||
Username string `json:"username"` //测试
|
||||
Password string `json:"password"`//测试2
|
||||
}
|
||||
|
||||
UserInfoReq {
|
||||
Id string `path:"id"`
|
||||
}
|
||||
|
@ -16,6 +16,31 @@
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/api/user/login": {
|
||||
"post": {
|
||||
"summary": "登录",
|
||||
"operationId": "login",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/LoginReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"user-api"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/user/register": {
|
||||
"post": {
|
||||
"summary": "注册",
|
||||
@ -40,9 +65,78 @@
|
||||
"user-api"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/user/search": {
|
||||
"get": {
|
||||
"summary": "用户搜索",
|
||||
"operationId": "searchUser",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UserInfoReply"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "keyWord",
|
||||
"description": " 关键词",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"user-api"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/user/{id}": {
|
||||
"get": {
|
||||
"summary": "获取用户信息",
|
||||
"operationId": "getUserInfo",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UserInfoReply"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"user-api"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"LoginReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string",
|
||||
"description": "测试"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"description": "测试2"
|
||||
}
|
||||
},
|
||||
"title": "LoginReq",
|
||||
"required": [
|
||||
"username",
|
||||
"password"
|
||||
]
|
||||
},
|
||||
"RegisterReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -62,6 +156,63 @@
|
||||
"password",
|
||||
"mobile"
|
||||
]
|
||||
},
|
||||
"UserInfoReply": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"age": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"birthday": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": "UserInfoReply",
|
||||
"required": [
|
||||
"name",
|
||||
"age",
|
||||
"birthday",
|
||||
"description",
|
||||
"tag"
|
||||
]
|
||||
},
|
||||
"UserInfoReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"title": "UserInfoReq",
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"UserSearchReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"keyWord": {
|
||||
"type": "string",
|
||||
"description": " 关键词"
|
||||
}
|
||||
},
|
||||
"title": "UserSearchReq",
|
||||
"required": [
|
||||
"keyWord"
|
||||
]
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
|
@ -232,7 +232,9 @@ func renderReplyAsDefinition(d swaggerDefinitionsObject, m messageMap, p []spec.
|
||||
|
||||
for _, tag := range member.Tags() {
|
||||
if len(tag.Options) == 0 {
|
||||
if !contains(schema.Required, tag.Name) && tag.Name != "required" {
|
||||
schema.Required = append(schema.Required, tag.Name)
|
||||
}
|
||||
continue
|
||||
}
|
||||
for _, option := range tag.Options {
|
||||
|
Loading…
x
Reference in New Issue
Block a user