From f2b5c10ba63b032039b3029d04617e7169e8ac71 Mon Sep 17 00:00:00 2001 From: kooksee Date: Tue, 31 Oct 2023 17:49:09 +0800 Subject: [PATCH] fix --- opendoc/consts.go | 3 +++ opendoc/util.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/opendoc/consts.go b/opendoc/consts.go index 8ae81a6..a6b5874 100644 --- a/opendoc/consts.go +++ b/opendoc/consts.go @@ -10,6 +10,9 @@ const ( description = "description" validate = "validate" required = "required" + readOnly = "readOnly" + writeOnly = "writeOnly" + example = "example" jsonTag = "json" queryTag = "query" diff --git a/opendoc/util.go b/opendoc/util.go index 9d60609..b9dc128 100644 --- a/opendoc/util.go +++ b/opendoc/util.go @@ -187,6 +187,9 @@ func genSchema(val interface{}) (ref string, schema *openapi3.Schema) { fieldSchema.AllowEmptyValue = true getTag(tags, nullable, func(_ *structtag.Tag) { fieldSchema.Nullable = true }) + getTag(tags, readOnly, func(_ *structtag.Tag) { fieldSchema.ReadOnly = true }) + getTag(tags, writeOnly, func(_ *structtag.Tag) { fieldSchema.WriteOnly = true }) + getTag(tags, example, func(tag *structtag.Tag) { fieldSchema.Example = tag.Name }) getTag(tags, required, func(_ *structtag.Tag) { fieldSchema.AllowEmptyValue = false }) getTag(tags, doc, func(tag *structtag.Tag) { fieldSchema.Description = tag.Name }) getTag(tags, description, func(tag *structtag.Tag) { fieldSchema.Description = tag.Name })