add exampleOption support
This commit is contained in:
@ -23,6 +23,7 @@ const (
|
||||
omitemptyOption = "omitempty"
|
||||
optionsOption = "options"
|
||||
rangeOption = "range"
|
||||
exampleOption = "example"
|
||||
optionSeparator = "|"
|
||||
equalToken = "="
|
||||
)
|
||||
@ -189,6 +190,13 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge
|
||||
} else if strings.HasPrefix(option, optionalOption) || strings.HasPrefix(option, omitemptyOption) {
|
||||
required = false
|
||||
}
|
||||
|
||||
if strings.HasPrefix(option, exampleOption) {
|
||||
segs := strings.Split(option, equalToken)
|
||||
if len(segs) == 2 {
|
||||
sp.Example = segs[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
sp.Required = required
|
||||
}
|
||||
@ -358,6 +366,13 @@ func renderStruct(member spec.Member) swaggerParameterObject {
|
||||
} else if strings.HasPrefix(option, optionalOption) || strings.HasPrefix(option, omitemptyOption) {
|
||||
required = false
|
||||
}
|
||||
|
||||
if strings.HasPrefix(option, exampleOption) {
|
||||
segs := strings.Split(option, equalToken)
|
||||
if len(segs) == 2 {
|
||||
sp.Example = segs[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
sp.Required = required
|
||||
}
|
||||
@ -572,6 +587,11 @@ func schemaOfField(member spec.Member) swaggerSchemaObject {
|
||||
ret.Maximum = max
|
||||
}
|
||||
}
|
||||
case strings.HasPrefix(option, exampleOption):
|
||||
segs := strings.Split(option, equalToken)
|
||||
if len(segs) == 2 {
|
||||
ret.Example = segs[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user