fix(parser.go): 修复validate字段的bug
1.添加validateKey 2.生成时忽略validate字段
This commit is contained in:
parent
c76c668b5f
commit
11e374395b
@ -18,6 +18,7 @@ import (
|
|||||||
var strColon = []byte(":")
|
var strColon = []byte(":")
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
validateKey = "validate"
|
||||||
defaultOption = "default"
|
defaultOption = "default"
|
||||||
stringOption = "string"
|
stringOption = "string"
|
||||||
optionalOption = "optional"
|
optionalOption = "optional"
|
||||||
@ -390,6 +391,10 @@ func renderStruct(member spec.Member) swaggerParameterObject {
|
|||||||
sp := swaggerParameterObject{In: "query", Type: ftype, Format: format}
|
sp := swaggerParameterObject{In: "query", Type: ftype, Format: format}
|
||||||
|
|
||||||
for _, tag := range member.Tags() {
|
for _, tag := range member.Tags() {
|
||||||
|
if tag.Key == validateKey {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
sp.Name = tag.Name
|
sp.Name = tag.Name
|
||||||
if len(tag.Options) == 0 {
|
if len(tag.Options) == 0 {
|
||||||
sp.Required = true
|
sp.Required = true
|
||||||
@ -491,6 +496,9 @@ func renderReplyAsDefinition(d swaggerDefinitionsObject, m messageMap, p []spec.
|
|||||||
*schema.Properties = append(*schema.Properties, kv)
|
*schema.Properties = append(*schema.Properties, kv)
|
||||||
|
|
||||||
for _, tag := range member.Tags() {
|
for _, tag := range member.Tags() {
|
||||||
|
if tag.Key == validateKey {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if len(tag.Options) == 0 {
|
if len(tag.Options) == 0 {
|
||||||
if !contains(schema.Required, tag.Name) && tag.Name != "required" {
|
if !contains(schema.Required, tag.Name) && tag.Name != "required" {
|
||||||
schema.Required = append(schema.Required, tag.Name)
|
schema.Required = append(schema.Required, tag.Name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user