liuxiran commented on issue #2082:
URL: https://github.com/apache/apisix/issues/2082#issuecomment-723914491


   After communicating with @LiteSun, there are three problems with the 
**request validation schema** design of the first edition:
   
   1. dirty data: when change from body_schema to header_schema, useless 
`body_schema` will be generated, and it can not be tranform to UI. 
   **try to update the transform schema to** the follow one
   ```json
   {
       "type": "object",
       "properties": {
         "requestParams": {
           "title": "define request paramers",
           "type": "array",
           "items": {
             "type": "object",
             "$ref": "#/definitions/requestParams"
           },
           "minItems": 1
         }
       },
       "definitions": {
         "requestParams": {
           "type": "object",
           "properties": {
             "schema": {
               "type": "string",
               "enum": [
                 "body_schema",
                 "header_schema"
               ]
             },
             "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"
                   ]
                 }
               ]
             }
           },
           "required": ["schema", "key", "valueType"]
         }
       }
     }
   ```
   2. how to handle parameters with the same name in the same section? as  user 
may have inadvertently defined two parameters with the same name.  **I prefer 
to covers the former with the latest one**.
   3. how to handle the order in which parameters are defined? as we have to 
transform the data before it posted to the API, it will  disrupt the order in 
which the parameters were originally defined. **I prefer to ignore the order,  
because the order of parameters does not affect the result of calling the api**
   
    


----------------------------------------------------------------
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