liuxiran edited a comment on issue #2082:
URL: https://github.com/apache/apisix/issues/2082#issuecomment-721552396


   > Added here for tracking #2432 .
   > 
   > * [x]  request-validation
   
   After the schema draft updated in APISIX, **request-validation** also needs 
to transform the schema at plugin componet, so that it can work properly in 
dashboard, just like proxy-rewrite do. @juzhiyuan 
   
   - the schema turned by APISIX:
   ```json
   {
        "anyOf": [{
                "properties": {
                        "body_schema": {
                                "type": "object"
                        }
                },
                "required": ["body_schema"],
                "title": "Body schema"
        }, {
                "properties": {
                        "header_schema": {
                                "type": "object"
                        }
                },
                "required": ["header_schema"],
                "title": "Header schema"
        }],
        "type": "object"
   }
   ```
   - dashboard needs to transform the schema to:
   ```json
   {
       "type": "object",
       "properties": {
         "requestParams": {
           "title": "define request paramers",
           "type": "array",
           "items": {
             "type": "object",
             "anyOf": [
               {
                 "title": "define body params",
                 "properties": {
                   "body_schema": {
                     "$ref": "#/definitions/requestParams"
                   }
                 },
                 "required": ["body_schema"],
                 "minItems": 1
               },
               {
                 "title": "define header params",
                 "properties": {
                   "header_schema": {
                     "$ref": "#/definitions/requestParams"
                   }
                 },
                 "required": ["header_schema"],
                 "minItems": 1
               }
             ]
           },
           "minItems": 1
         }
       },
       "definitions": {
         "requestParams": {
           "type": "object",
           "properties": {
             "key": {
               "type": "string"
             },
             "valueType": {
               "type": "string",
               "enum": [
                 "string",
                 "array",
                 "integer",
                 "number",
                 "object",
                 "boolean"
               ]
             },
             "required": {
               "type": "boolean"
             }
           },
           "dependencies": {
             "valueType": {
               "oneOf": [
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "string"
                       ]
                     },
                     "minLength": {
                       "type": "integer"
                     },
                     "maxLength": {
                       "type": "integer"
                     },
                     "pattern": {
                       "type": "string"
                     },
                     "enumValues": {
                       "type": "array",
                       "items": {
                         "type": "string"
                       }
                     }
                   },
                   "required": ["valueType"]
                 },
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "array"
                       ]
                     },
                     "minItems": {
                       "type": "integer"
                     },
                     "itemsType": {
                       "type": "string",
                       "enum": [
                         "string",
                         "array",
                         "integer",
                         "number",
                         "object",
                         "boolean"
                       ]
                     },
                     "uniqueItems": {
                       "type": "boolean"
                     }
                   },
                   "required": [
                     "valueType"
                   ]
                 },
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "integer"
                       ]
                     },
                     "minimum": {
                       "type": "integer"
                     },
                     "maximum": {
                       "type": "integer"
                     }
                   },
                   "required": [
                     "valueType"
                   ]
                 },
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "number"
                       ]
                     },
                     "minimum": {
                       "type": "number"
                     },
                     "maximum": {
                       "type": "number"
                     }
                   },
                   "required": [
                     "valueType"
                   ]
                 },
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "object"
                       ]
                     }
                   },
                   "required": [
                     "valueType"
                   ]
                 },
                 {
                   "properties": {
                     "valueType": {
                       "enum": [
                         "boolean"
                       ]
                     }
                   },
                   "required": [
                     "valueType"
                   ]
                 }
               ]
             }
           }
         }
       }
     }
   ``` 
   
   - the config page in dashboard looks like:
   
   
   
   ![2020-11-04 
15-04-20屏幕截图](https://user-images.githubusercontent.com/2561857/98079645-1e379000-1eaf-11eb-8633-cd90e22c0f24.png)
   
   


----------------------------------------------------------------
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:
[email protected]


Reply via email to