Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee committed Oct 31, 2023
1 parent 634b760 commit f2b5c10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions opendoc/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const (
description = "description"
validate = "validate"
required = "required"
readOnly = "readOnly"
writeOnly = "writeOnly"
example = "example"

jsonTag = "json"
queryTag = "query"
Expand Down
3 changes: 3 additions & 0 deletions opendoc/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit f2b5c10

Please sign in to comment.