This commit is contained in:
Shreyas Goenka 2024-09-06 15:30:32 +02:00
parent 75a571a56d
commit 8cd26318e8
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 7 additions and 2 deletions

View File

@ -81,7 +81,7 @@ func (c *constructor) Definitions() map[string]any {
return res
}
// FromType converts a reflect.Type to a jsonschema.Schema. Nodes in the final JSON
// FromType converts a [reflect.Type] to a [Schema]. Nodes in the final JSON
// schema are guaranteed to be one level deep, which is done using defining $defs
// for every Go type and referring them using $ref in the corresponding node in
// the JSON schema.
@ -253,11 +253,16 @@ func (c *constructor) fromTypeStruct(typ reflect.Type) (Schema, error) {
bundleTags := strings.Split(structField.Tag.Get("bundle"), ",")
// Fields marked as "readonly", "internal" or "deprecated" are skipped
// while generating the schema
skip := false
for _, tag := range skipTags {
if slices.Contains(bundleTags, tag) {
continue
skip = true
break
}
}
if skip {
continue
}
jsonTags := strings.Split(structField.Tag.Get("json"), ",")
fieldName := jsonTags[0]