增加示例值解析 + 优化schema属性配置

This commit is contained in:
2025-02-20 16:22:23 +08:00
parent bd7f6d2cfd
commit d7cbf81799
4 changed files with 65 additions and 59 deletions

View File

@ -155,6 +155,7 @@ type Property struct {
XEnumDescription map[string]string `json:"x-enumDescriptions,omitempty"` // 枚举值描述的扩展, redoc-free支持
Default any `json:"default,omitempty"` // 默认值 : 不同于 JSON Schema这个值必须符合定义与相同级别的 Schema 对象 中定义的类型,比如 type 是 string那么 default 可以是 "foo" 但不能是 1。
Description string `json:"description,omitempty"` // 数据描述, CommonMark syntax可以被用来呈现富文本格式.
Example string `json:"example,omitempty"` // 媒体类型的示例。示例对象应该符合此媒体类型的格式, 这里指定的example对象 object is mutually exclusive of the examples object. 而且如果引用的schema也包含示例在这里指定的example值将会覆盖schema提供的示例。
Maximum *int64 `json:"maximum,omitempty"` // 最大值
Minimum *int64 `json:"minimum,omitempty"` // 最小值
MinLength *int64 `json:"minLength,omitempty"` // 字符串最小长度

View File

@ -29,6 +29,8 @@ const (
TagUriTag = "tag" // 接口的tag
TagOutputStrict = "output_strict" // 接口数据是否为严格模式 : 严格模式, 响应数据必须是结构体/map非严格模式返回任意值
TagErrMsg = "err" // 验证失败错误信息tag
TagExample = "example" // 示例值
TagEg = "eg" // 示例值
TagContentType = "content_type"
TagOutputContentType = "output_content_type"
TagNameOmitempty = "omitempty"