From 00939d3835fe25eba6c60a13d98500dc545c34c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 19 Jul 2024 17:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84schema=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define/openapi.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/define/openapi.go b/define/openapi.go index 3a29f5a..4cc93ab 100644 --- a/define/openapi.go +++ b/define/openapi.go @@ -124,6 +124,23 @@ type Schema struct { // // Date : 17:05 2024/7/19 type Property struct { + Type string `json:"type"` // 数据类型, swagger本身的定义 + Format string `json:"format"` // 对应编程语言中的数据类型描述 + Default any `json:"default"` // 默认值 : 不同于 JSON Schema,这个值必须符合定义与相同级别的 Schema 对象 中定义的类型,比如 type 是 string,那么 default 可以是 "foo" 但不能是 1。 + Description string `json:"description"` // 数据描述, CommonMark syntax可以被用来呈现富文本格式. + AllOf []*PropertyXOf `json:"allOf"` // type 是一个对象, allOf 指向对象描述 + OneOf []*PropertyXOf `json:"oneOf"` // type 是一个对象, allOf 指向对象描述 + AnyOf []*PropertyXOf `json:"anyOf"` // type 是一个对象, allOf 指向对象描述 + Items *PropertyXOf `json:"items"` // items 必须存在如果 type 的值是 array。 +} + +// PropertyXOf ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:13 2024/7/19 +type PropertyXOf struct { + Ref string `json:"$ref"` // 引用的结构描述 } // SchemaDiscriminator 当一个 request bodies 或 response payloads 可以是多种 schemas 时,可以使用一个 discriminator 对象来帮助序列化、反序列化和校验