Remove the repeated Required tag
This commit is contained in:
parent
05cdea3e7c
commit
80775cf7ef
@ -18,7 +18,6 @@ type (
|
|||||||
Username string `json:"username"` //测试
|
Username string `json:"username"` //测试
|
||||||
Password string `json:"password"`//测试2
|
Password string `json:"password"`//测试2
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfoReq {
|
UserInfoReq {
|
||||||
Id string `path:"id"`
|
Id string `path:"id"`
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,31 @@
|
|||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"paths": {
|
"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": {
|
"/api/user/register": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "注册",
|
"summary": "注册",
|
||||||
@ -40,9 +65,78 @@
|
|||||||
"user-api"
|
"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": {
|
"definitions": {
|
||||||
|
"LoginReq": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"username": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "测试"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "测试2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"title": "LoginReq",
|
||||||
|
"required": [
|
||||||
|
"username",
|
||||||
|
"password"
|
||||||
|
]
|
||||||
|
},
|
||||||
"RegisterReq": {
|
"RegisterReq": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -62,6 +156,63 @@
|
|||||||
"password",
|
"password",
|
||||||
"mobile"
|
"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": {
|
"securityDefinitions": {
|
||||||
|
@ -232,7 +232,9 @@ func renderReplyAsDefinition(d swaggerDefinitionsObject, m messageMap, p []spec.
|
|||||||
|
|
||||||
for _, tag := range member.Tags() {
|
for _, tag := range member.Tags() {
|
||||||
if len(tag.Options) == 0 {
|
if len(tag.Options) == 0 {
|
||||||
|
if !contains(schema.Required, tag.Name) && tag.Name != "required" {
|
||||||
schema.Required = append(schema.Required, tag.Name)
|
schema.Required = append(schema.Required, tag.Name)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, option := range tag.Options {
|
for _, option := range tag.Options {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user