fix: is the root folder required (close #1633)

This commit is contained in:
Noah Hsu
2022-09-11 16:23:46 +08:00
parent fba1471ec4
commit 969018db37
3 changed files with 11 additions and 12 deletions

View File

@ -28,11 +28,11 @@ type IRootId interface {
}
type RootPath struct {
RootFolderPath string `json:"root_folder_path" required:"true"`
RootFolderPath string `json:"root_folder_path"`
}
type RootID struct {
RootFolderID string `json:"root_folder_id" required:"true"`
RootFolderID string `json:"root_folder_id"`
}
func (r RootPath) GetRootPath() string {

View File

@ -145,8 +145,11 @@ func getAdditionalItems(t reflect.Type, defaultRoot string) []driver.Item {
if tag.Get("type") != "" {
item.Type = tag.Get("type")
}
if (item.Name == "root_folder_id" || item.Name == "root_folder_path") && item.Default == "" {
item.Default = defaultRoot
if item.Name == "root_folder_id" || item.Name == "root_folder_path" {
if item.Default == "" {
item.Default = defaultRoot
}
item.Required = item.Default != ""
}
// set default type to string
if item.Type == "" {