nic-chen commented on a change in pull request #904:
URL: https://github.com/apache/apisix-dashboard/pull/904#discussion_r535762067



##########
File path: api/internal/core/store/validate.go
##########
@@ -238,22 +238,37 @@ func (v *APISIXJsonSchemaValidator) Validate(obj 
interface{}) error {
                return err
        }
 
+       pluginDisableSchema := map[string]map[string]interface{}{
+               "disable": {"type": "boolean"},
+       }
        plugins, schemaType := getPlugins(obj)
-       //fix lua json.encode transform lua{properties={}} to 
json{"properties":[]}
-       reg := regexp.MustCompile(`\"properties\":\[\]`)
        for pluginName, pluginConf := range plugins {
-               var schemaDef string
-               schemaDef = conf.Schema.Get("plugins." + pluginName + "." + 
schemaType).String()
-               if schemaDef == "" && schemaType == "consumer_schema" {
-                       schemaDef = conf.Schema.Get("plugins." + pluginName + 
".schema").String()
+               schemaValue := conf.Schema.Get("plugins." + pluginName + "." + 
schemaType).Value()
+               if schemaValue == nil && schemaType == "consumer_schema" {
+                       schemaValue = conf.Schema.Get("plugins." + pluginName + 
".schema").Value()
                }
-               if schemaDef == "" {
-                       log.Warnf("schema validate failed: schema not found, 
path: %s", "plugins."+pluginName)
+               if schemaValue == nil {
+                       log.Warnf("schema validate failed: schema not found,  
%s, %s", "plugins."+pluginName, schemaType)
                        return fmt.Errorf("schema validate failed: schema not 
found, path: %s", "plugins."+pluginName)
                }
+               schemaMap := schemaValue.(map[string]interface{})
+               if schemaMap["type"] != nil && schemaMap["type"].(string) == 
"object" {
+                       if properties, ok := schemaMap["properties"]; ok {

Review comment:
       @ShiningRush  we only care about `properties` is nil or empty. please 
refer: https://github.com/apache/apisix/pull/2099/files




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to